Skip to content

Commit 51315a9

Browse files
committed
fix
1 parent 868dd3e commit 51315a9

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/jdbc/env/internal/ReactiveMutationExecutor.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ default CompletionStage<GeneratedValues> executeReactive(
5858
TableInclusionChecker inclusionChecker,
5959
OperationResultChecker resultChecker,
6060
SharedSessionContractImplementor session) {
61-
return executeReactive( modelReference, valuesAnalysis, inclusionChecker, resultChecker, session, true );
61+
return executeReactive( modelReference, valuesAnalysis, inclusionChecker, resultChecker, session, true, null );
6262
}
6363

6464
default CompletionStage<GeneratedValues> executeReactive(
@@ -67,8 +67,9 @@ default CompletionStage<GeneratedValues> executeReactive(
6767
TableInclusionChecker inclusionChecker,
6868
OperationResultChecker resultChecker,
6969
SharedSessionContractImplementor session,
70-
boolean isIdentityInsert) {
71-
return performReactiveNonBatchedOperations( modelReference, valuesAnalysis, inclusionChecker, resultChecker, session, isIdentityInsert )
70+
boolean isIdentityInsert,
71+
String[] identifierColumnsNames) {
72+
return performReactiveNonBatchedOperations( modelReference, valuesAnalysis, inclusionChecker, resultChecker, session, isIdentityInsert, identifierColumnsNames )
7273
.thenCompose( generatedValues -> performReactiveSelfExecutingOperations( valuesAnalysis, inclusionChecker, session )
7374
.thenCompose( v -> performReactiveBatchedOperations( valuesAnalysis, inclusionChecker, resultChecker, session ) )
7475
.thenApply( v -> generatedValues )
@@ -81,7 +82,8 @@ default CompletionStage<GeneratedValues> performReactiveNonBatchedOperations(
8182
TableInclusionChecker inclusionChecker,
8283
OperationResultChecker resultChecker,
8384
SharedSessionContractImplementor session,
84-
boolean isIdentityInsert) {
85+
boolean isIdentityInsert,
86+
String[] identifierColumnsNames) {
8587
return nullFuture();
8688
}
8789

@@ -160,7 +162,8 @@ default CompletionStage<Void> performReactiveNonBatchedMutation(
160162
JdbcValueBindings valueBindings,
161163
TableInclusionChecker inclusionChecker,
162164
OperationResultChecker resultChecker,
163-
SharedSessionContractImplementor session) {
165+
SharedSessionContractImplementor session,
166+
String[] identifierColumnsNames) {
164167
if ( statementDetails == null ) {
165168
return nullFuture();
166169
}
@@ -195,7 +198,10 @@ default CompletionStage<Void> performReactiveNonBatchedMutation(
195198

196199
Dialect dialect = session.getJdbcServices().getDialect();
197200
ReactiveConnection reactiveConnection = ( (ReactiveConnectionSupplier) session ).getReactiveConnection();
198-
String sqlString = createInsert( statementDetails.getSqlString(), "id", dialect );
201+
String sqlString = statementDetails.getSqlString();
202+
if ( identifierColumnsNames != null ) {
203+
sqlString = createInsert( statementDetails.getSqlString(), identifierColumnsNames[0], dialect );
204+
}
199205
return reactiveConnection
200206
.update( sqlString, params )
201207
.thenCompose( affectedRowCount -> {

hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/jdbc/mutation/internal/ReactiveMutationExecutorSingleNonBatched.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public CompletionStage<GeneratedValues> performReactiveNonBatchedOperations(
4545
TableInclusionChecker inclusionChecker,
4646
OperationResultChecker resultChecker,
4747
SharedSessionContractImplementor session,
48-
boolean isIdentityInsert) {
48+
boolean isIdentityInsert,
49+
String[] identifierColumnsNames) {
4950
PreparedStatementDetails singleStatementDetails = getStatementGroup().getSingleStatementDetails();
5051
if ( generatedValuesDelegate != null && !isRegularInsertWithMariaDb( session, isIdentityInsert ) ) {
5152
return generatedValuesDelegate.reactivePerformMutation(
@@ -61,7 +62,8 @@ public CompletionStage<GeneratedValues> performReactiveNonBatchedOperations(
6162
getJdbcValueBindings(),
6263
inclusionChecker,
6364
resultChecker,
64-
session
65+
session,
66+
identifierColumnsNames
6567
).thenCompose( CompletionStages::nullFuture );
6668
}
6769

hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/jdbc/mutation/internal/ReactiveMutationExecutorStandard.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public CompletionStage<GeneratedValues> performReactiveNonBatchedOperations(
110110
TableInclusionChecker inclusionChecker,
111111
OperationResultChecker resultChecker,
112112
SharedSessionContractImplementor session,
113-
boolean isIndentityInsert) {
113+
boolean isIndentityInsert,
114+
String[] identifiersColumnsNames) {
114115

115116
if ( getNonBatchedStatementGroup() == null || getNonBatchedStatementGroup().getNumberOfStatements() <= 0 ) {
116117
return nullFuture();
@@ -186,7 +187,7 @@ public void add(String tableName, PreparedStatementDetails statementDetails) {
186187
if ( requiresCheck ) {
187188
loop = loop.thenCompose( v -> !statementDetails
188189
.getMutatingTableDetails().isIdentifierTable()
189-
? performReactiveNonBatchedMutation( statementDetails, id, jdbcValueBindings, inclusionChecker, resultChecker, session )
190+
? performReactiveNonBatchedMutation( statementDetails, id, jdbcValueBindings, inclusionChecker, resultChecker, session, null )
190191
: voidFuture()
191192
);
192193
}
@@ -197,7 +198,8 @@ public void add(String tableName, PreparedStatementDetails statementDetails) {
197198
jdbcValueBindings,
198199
inclusionChecker,
199200
resultChecker,
200-
session
201+
session,
202+
null
201203
) );
202204
}
203205
}
@@ -213,7 +215,8 @@ public CompletionStage<Void> performReactiveNonBatchedMutation(
213215
JdbcValueBindings valueBindings,
214216
TableInclusionChecker inclusionChecker,
215217
OperationResultChecker resultChecker,
216-
SharedSessionContractImplementor session) {
218+
SharedSessionContractImplementor session,
219+
String[] identifierColumnsNames) {
217220
if ( statementDetails == null ) {
218221
return voidFuture();
219222
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/mutation/ReactiveDeleteCoordinator.java

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ protected void doStaticDelete(Object entity, Object id, Object rowId, Object[] l
142142
final JdbcValueBindings jdbcValueBindings = mutationExecutor.getJdbcValueBindings();
143143
bindPartitionColumnValueBindings( loadedState, session, jdbcValueBindings );
144144
applyId( id, rowId, mutationExecutor, getStaticMutationOperationGroup(), session );
145+
String[] identifierColumnNames = entityPersister().getIdentifierColumnNames();
145146
mutationExecutor.executeReactive(
146147
entity,
147148
null,

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/mutation/ReactiveInsertCoordinatorStandard.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ protected CompletionStage<GeneratedValues> doDynamicInserts(
232232
return true;
233233
},
234234
session,
235-
isIdentityInsert
235+
isIdentityInsert,
236+
entityPersister().getIdentifierColumnNames()
236237
)
237238
.whenComplete( (o, t) -> mutationExecutor.release() ) );
238239
}
@@ -252,7 +253,8 @@ protected CompletionStage<GeneratedValues> doStaticInserts(Object id, Object[] v
252253
return true;
253254
},
254255
session,
255-
isIdentityInsert
256+
isIdentityInsert,
257+
entityPersister().getIdentifierColumnNames()
256258
) )
257259
.whenComplete( (generatedValues, throwable) -> mutationExecutor.release() );
258260
}

0 commit comments

Comments
 (0)