1010import  org .hibernate .engine .spi .QueryParameters ;
1111import  org .hibernate .param .ParameterSpecification ;
1212import  org .hibernate .reactive .adaptor .impl .QueryParametersAdaptor ;
13- import  org .hibernate .reactive .pool .ReactiveConnection ;
1413import  org .hibernate .reactive .session .ReactiveQueryExecutor ;
15- import  org .hibernate .reactive .util .impl .CompletionStages ;
1614
1715import  static  org .hibernate .reactive .util .impl .CompletionStages .total ;
1816
19- 
2017/** 
2118 * A list of SQL statements to be executed as a single logical unit. 
2219 * May include both DDL and DML statements. 
@@ -35,55 +32,17 @@ public interface StatementsWithParameters {
3532     */ 
3633    ParameterSpecification [][] getParameterSpecifications ();
3734
38-     /** 
39-      * Is the given statement executed inside the current transaction? 
40-      * 
41-      * @return true by default 
42-      */ 
43-     default  boolean  isTransactionalStatement (String  statement ) {
44-         return  true ;
45-     }
46- 
47-     /** 
48-      * Should the result of this statement contribute to the running 
49-      * updated row count? 
50-      * 
51-      * @return false for DDL statements by default 
52-      */ 
53-     default  boolean   isSchemaDefinitionStatement (String  statement ) {
54-         return  statement .startsWith ("create " )
55-             || statement .startsWith ("drop " );
56-     }
57- 
5835    /** 
5936     * Execute the statements using the query parameters 
6037     */ 
6138    default  CompletionStage <Integer > execute (ReactiveQueryExecutor  session , QueryParameters  queryParameters ) {
6239        return  total ( 0 , getSqlStatements ().length , i  -> {
63-             final  String  sql  = getSqlStatements ()[i ];
64-             ReactiveConnection  connection  = session .getReactiveConnection ();
65-             if  ( !isSchemaDefinitionStatement ( sql  ) ) {
66-                 final  Object [] arguments  = QueryParametersAdaptor .arguments (
67-                         queryParameters ,
68-                         getParameterSpecifications ()[i ],
69-                         session .getSharedContract ()
70-                 );
71-                 return  connection .update ( sql , arguments  );
72-             }
73-             else  if  ( isTransactionalStatement ( sql  ) ) {
74-                 // a DML statement that should be executed within the 
75-                 // transaction (local temporary tables) 
76-                 return  connection .execute ( sql  )
77-                         .thenCompose ( CompletionStages ::zeroFuture  );
78-             }
79-             else  {
80-                 // a DML statement that should be executed outside the 
81-                 // transaction (global temporary tables) 
82-                 return  connection .executeOutsideTransaction ( sql  )
83-                         // ignore errors creating tables, since a create 
84-                         // table fails whenever the table already exists 
85-                         .handle ( (v , x ) -> 0  );
86-             }
40+             final  Object [] arguments  = QueryParametersAdaptor .arguments (
41+                     queryParameters ,
42+                     getParameterSpecifications ()[i ],
43+                     session .getSharedContract ()
44+             );
45+             return  session .getReactiveConnection ().update ( getSqlStatements ()[i ], arguments  );
8746        } );
8847    }
8948}
0 commit comments