Skip to content

Commit 5daf463

Browse files
committed
fix
1 parent efdc714 commit 5daf463

22 files changed

+206
-433
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/generator/values/ReactiveInsertGeneratedIdentifierDelegate.java

-116
This file was deleted.

hibernate-reactive-core/src/main/java/org/hibernate/reactive/generator/values/internal/ReactiveGeneratedValuesHelper.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ public class ReactiveGeneratedValuesHelper {
6363
*
6464
* @see GeneratedValuesHelper#getGeneratedValuesDelegate(EntityPersister, EventType)
6565
*/
66-
public static GeneratedValuesMutationDelegate getGeneratedValuesDelegate(
67-
EntityPersister persister,
68-
EventType timing) {
66+
public static GeneratedValuesMutationDelegate getGeneratedValuesDelegate(EntityPersister persister, EventType timing) {
6967
final boolean hasGeneratedProperties = !persister.getGeneratedProperties( timing ).isEmpty();
7068
final boolean hasRowId = timing == EventType.INSERT && persister.getRowIdMapping() != null;
7169
final Dialect dialect = persister.getFactory().getJdbcServices().getDialect();
7270

73-
if ( hasRowId && dialect.supportsInsertReturning() && dialect.supportsInsertReturningRowId()
71+
if ( hasRowId
72+
&& dialect.supportsInsertReturning()
73+
&& dialect.supportsInsertReturningRowId()
7474
&& noCustomSql( persister, timing ) ) {
7575
// Special case for RowId on INSERT, since GetGeneratedKeysDelegate doesn't support it
7676
// make InsertReturningDelegate the preferred method if the dialect supports it

hibernate-reactive-core/src/main/java/org/hibernate/reactive/id/insert/ReactiveInsertReturningDelegate.java

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public class ReactiveInsertReturningDelegate extends AbstractReturningDelegate i
5050
private final MutatingTableReference tableReference;
5151
private final List<ColumnReference> generatedColumns;
5252

53+
public ReactiveInsertReturningDelegate(EntityPersister persister, EventType timing) {
54+
this( persister, timing, false );
55+
}
56+
5357
public ReactiveInsertReturningDelegate(EntityPersister persister, Dialect dialect) {
5458
// With JDBC it's possible to enabled GetGeneratedKeys for identity generation.
5559
// Vert.x doesn't have this option, so we always use the same strategy for all database.

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveAbstractEntityPersister.java

+7-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
package org.hibernate.reactive.persister.entity.impl;
77

8-
import java.lang.invoke.MethodHandles;
98
import java.sql.PreparedStatement;
109
import java.sql.ResultSet;
1110
import java.sql.SQLException;
@@ -43,7 +42,6 @@
4342
import org.hibernate.reactive.loader.ast.internal.ReactiveSingleIdArrayLoadPlan;
4443
import org.hibernate.reactive.loader.ast.spi.ReactiveSingleIdEntityLoader;
4544
import org.hibernate.reactive.logging.impl.Log;
46-
import org.hibernate.reactive.logging.impl.LoggerFactory;
4745
import org.hibernate.reactive.metamodel.mapping.internal.ReactiveCompoundNaturalIdMapping;
4846
import org.hibernate.reactive.metamodel.mapping.internal.ReactiveSimpleNaturalIdMapping;
4947
import org.hibernate.reactive.pool.ReactiveConnection;
@@ -58,11 +56,13 @@
5856

5957
import jakarta.persistence.metamodel.Attribute;
6058

59+
import static java.lang.invoke.MethodHandles.lookup;
6160
import static java.util.Collections.emptyMap;
6261
import static org.hibernate.generator.EventType.INSERT;
6362
import static org.hibernate.generator.EventType.UPDATE;
6463
import static org.hibernate.internal.util.collections.CollectionHelper.setOfSize;
6564
import static org.hibernate.pretty.MessageHelper.infoString;
65+
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
6666
import static org.hibernate.reactive.util.impl.CompletionStages.completedFuture;
6767
import static org.hibernate.reactive.util.impl.CompletionStages.failedFuture;
6868
import static org.hibernate.reactive.util.impl.CompletionStages.logSqlException;
@@ -90,8 +90,6 @@
9090
*/
9191
public interface ReactiveAbstractEntityPersister extends ReactiveEntityPersister {
9292

93-
Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );
94-
9593
default Parameters parameters() {
9694
return Parameters.instance( getFactory().getJdbcServices().getDialect() );
9795
}
@@ -259,6 +257,7 @@ default Object nextVersionForLock(LockMode lockMode, Object id, Object currentVe
259257
final Object nextVersion = getVersionJavaType()
260258
.next( currentVersion, versionMapping.getLength(), versionMapping.getPrecision(), versionMapping.getScale(), session );
261259

260+
Log LOG = make( Log.class, lookup() );
262261
if ( LOG.isTraceEnabled() ) {
263262
LOG.trace( "Forcing version increment [" + infoString( this, id, getFactory() ) + "; "
264263
+ versionType.toLoggableString( currentVersion, getFactory() ) + " -> "
@@ -289,6 +288,7 @@ default ReactiveSingleIdEntityLoader<?> getReactiveSingleIdEntityLoader() {
289288
*/
290289
@Override
291290
default CompletionStage<Object> reactiveGetCurrentVersion(Object id, SharedSessionContractImplementor session) {
291+
Log LOG = make( Log.class, lookup() );
292292
if ( LOG.isTraceEnabled() ) {
293293
LOG.tracev( "Getting version: {0}", infoString( this, id, getFactory() ) );
294294
}
@@ -379,7 +379,8 @@ default CompletionStage<Object> reactiveInitializeLazyPropertiesFromDatastore(
379379
throw new AssertionFailure( "Expecting bytecode interceptor to be non-null" );
380380
}
381381

382-
LOG.tracef( "Initializing lazy properties from datastore (triggered for `%s`)", fieldName );
382+
make( Log.class, lookup() )
383+
.tracef( "Initializing lazy properties from datastore (triggered for `%s`)", fieldName );
383384

384385
final String fetchGroup = getEntityPersister().getBytecodeEnhancementMetadata()
385386
.getLazyAttributesMetadata()
@@ -459,7 +460,7 @@ default CompletionStage<Object> initLazyProperty(
459460
}
460461

461462
return resultStage.thenApply( result -> {
462-
LOG.trace( "Done initializing lazy properties" );
463+
make( Log.class, lookup() ).trace( "Done initializing lazy properties" );
463464
return result;
464465
} );
465466
}
@@ -539,12 +540,8 @@ private CompletionStage<?> loadFromDatabaseOrCache(
539540

540541
Object initializeLazyProperty(String fieldName, Object entity, SharedSessionContractImplementor session);
541542

542-
String[][] getLazyPropertyColumnAliases();
543-
544543
ReactiveSingleIdArrayLoadPlan reactiveGetSQLLazySelectLoadPlan(String fetchGroup);
545544

546-
boolean isBatchable();
547-
548545
/**
549546
* @see AbstractEntityPersister#generateNaturalIdMapping(MappingModelCreationProcess, PersistentClass)
550547
*/

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveJoinedSubclassEntityPersister.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.hibernate.property.access.spi.PropertyAccess;
4545
import org.hibernate.reactive.loader.ast.internal.ReactiveSingleIdArrayLoadPlan;
4646
import org.hibernate.reactive.loader.ast.spi.ReactiveSingleUniqueKeyEntityLoader;
47+
import org.hibernate.reactive.logging.impl.Log;
4748
import org.hibernate.reactive.persister.entity.mutation.ReactiveDeleteCoordinator;
4849
import org.hibernate.reactive.persister.entity.mutation.ReactiveInsertCoordinatorStandard;
4950
import org.hibernate.reactive.persister.entity.mutation.ReactiveUpdateCoordinator;
@@ -54,13 +55,18 @@
5455
import org.hibernate.sql.results.graph.DomainResultCreationState;
5556
import org.hibernate.type.EntityType;
5657

58+
import static java.lang.invoke.MethodHandles.lookup;
59+
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
60+
5761
/**
5862
* An {@link ReactiveEntityPersister} backed by {@link JoinedSubclassEntityPersister}
5963
* and {@link ReactiveAbstractEntityPersister}.
6064
*/
6165
public class ReactiveJoinedSubclassEntityPersister extends JoinedSubclassEntityPersister
6266
implements ReactiveAbstractEntityPersister {
6367

68+
private static final Log LOG = make( Log.class, lookup() );
69+
6470
private final ReactiveAbstractPersisterDelegate reactiveDelegate;
6571

6672
public ReactiveJoinedSubclassEntityPersister(
@@ -291,11 +297,6 @@ public boolean initializeLazyProperty(String fieldName, Object entity, EntityEnt
291297
return super.initializeLazyProperty( fieldName, entity, entry, lazyIndex, selectedValue );
292298
}
293299

294-
@Override
295-
public String[][] getLazyPropertyColumnAliases() {
296-
return super.getLazyPropertyColumnAliases();
297-
}
298-
299300
/**
300301
* Process properties generated with an insert
301302
*

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveSingleTableEntityPersister.java

+6-16
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.hibernate.generator.Generator;
2424
import org.hibernate.generator.values.GeneratedValues;
2525
import org.hibernate.generator.values.GeneratedValuesMutationDelegate;
26-
import org.hibernate.id.insert.InsertGeneratedIdentifierDelegate;
2726
import org.hibernate.jdbc.Expectation;
2827
import org.hibernate.loader.ast.spi.MultiIdEntityLoader;
2928
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
@@ -47,9 +46,9 @@
4746
import org.hibernate.persister.entity.mutation.UpdateCoordinator;
4847
import org.hibernate.property.access.spi.PropertyAccess;
4948
import org.hibernate.reactive.generator.values.GeneratedValuesMutationDelegateAdaptor;
50-
import org.hibernate.reactive.generator.values.ReactiveInsertGeneratedIdentifierDelegate;
5149
import org.hibernate.reactive.loader.ast.internal.ReactiveSingleIdArrayLoadPlan;
5250
import org.hibernate.reactive.loader.ast.spi.ReactiveSingleUniqueKeyEntityLoader;
51+
import org.hibernate.reactive.logging.impl.Log;
5352
import org.hibernate.reactive.persister.entity.mutation.ReactiveAbstractDeleteCoordinator;
5453
import org.hibernate.reactive.persister.entity.mutation.ReactiveInsertCoordinatorStandard;
5554
import org.hibernate.reactive.persister.entity.mutation.ReactiveUpdateCoordinator;
@@ -60,13 +59,18 @@
6059
import org.hibernate.sql.results.graph.DomainResultCreationState;
6160
import org.hibernate.type.EntityType;
6261

62+
import static java.lang.invoke.MethodHandles.lookup;
63+
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
64+
6365

6466
/**
6567
* A {@link ReactiveEntityPersister} backed by {@link SingleTableEntityPersister}
6668
* and {@link ReactiveAbstractEntityPersister}.
6769
*/
6870
public class ReactiveSingleTableEntityPersister extends SingleTableEntityPersister implements ReactiveAbstractEntityPersister {
6971

72+
private static final Log LOG = make( Log.class, lookup() );
73+
7074
private ReactiveAbstractPersisterDelegate reactiveDelegate;
7175

7276
public ReactiveSingleTableEntityPersister(
@@ -147,15 +151,6 @@ public GeneratedValuesMutationDelegate getUpdateDelegate() {
147151
return new GeneratedValuesMutationDelegateAdaptor( updateDelegate );
148152
}
149153

150-
@Override
151-
public InsertGeneratedIdentifierDelegate getIdentityInsertDelegate() {
152-
final GeneratedValuesMutationDelegate insertDelegate = super.getInsertDelegate();
153-
if ( insertDelegate instanceof InsertGeneratedIdentifierDelegate ) {
154-
return new ReactiveInsertGeneratedIdentifierDelegate( (InsertGeneratedIdentifierDelegate) insertDelegate );
155-
}
156-
return null;
157-
}
158-
159154
@Override
160155
public <T> DomainResult<T> createDomainResult(
161156
NavigablePath navigablePath,
@@ -232,11 +227,6 @@ public Object initializeLazyPropertiesFromDatastore(final Object entity, final O
232227
return reactiveInitializeLazyPropertiesFromDatastore( entity, id, entry, fieldName, session );
233228
}
234229

235-
@Override
236-
public String[][] getLazyPropertyColumnAliases() {
237-
return super.getLazyPropertyColumnAliases();
238-
}
239-
240230
@Override
241231
public Object insert(Object[] fields, Object object, SharedSessionContractImplementor session) {
242232
throw LOG.nonReactiveMethodCall( "insertReactive" );

hibernate-reactive-core/src/main/java/org/hibernate/reactive/persister/entity/impl/ReactiveUnionSubclassEntityPersister.java

-5
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,6 @@ public Generator getGenerator() throws HibernateException {
187187
return reactiveDelegate.reactive( super.getGenerator() );
188188
}
189189

190-
@Override
191-
public String[][] getLazyPropertyColumnAliases() {
192-
return super.getLazyPropertyColumnAliases();
193-
}
194-
195190
@Override
196191
public boolean check(int rows, Object id, int tableNumber, Expectation expectation, PreparedStatement statement, String sql) throws HibernateException {
197192
return super.check(rows, id, tableNumber, expectation, statement, sql);

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,7 @@ public ReactiveInsertCoordinatorStandard(AbstractEntityPersister entityPersister
6969
batchKey = null;
7070
}
7171
else {
72-
batchKey = new BasicBatchKey(
73-
entityPersister.getEntityName() + "#INSERT",
74-
null
75-
);
72+
batchKey = new BasicBatchKey( entityPersister.getEntityName() + "#INSERT" );
7673
}
7774

7875
if ( entityPersister.getEntityMetamodel().isDynamicInsert() ) {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
99
import org.hibernate.engine.spi.SessionFactoryImplementor;
10-
import org.hibernate.persister.entity.AbstractEntityPersister;
10+
import org.hibernate.persister.entity.EntityPersister;
1111
import org.hibernate.persister.entity.mutation.EntityTableMapping;
1212
import org.hibernate.sql.model.MutationOperation;
1313
import org.hibernate.sql.model.MutationOperationGroup;
@@ -20,7 +20,7 @@
2020
*/
2121
public class ReactiveMergeCoordinator extends ReactiveUpdateCoordinatorStandard {
2222
public ReactiveMergeCoordinator(
23-
AbstractEntityPersister entityPersister,
23+
EntityPersister entityPersister,
2424
SessionFactoryImplementor factory,
2525
MutationOperationGroup staticUpdateGroup,
2626
BatchKey batchKey,

0 commit comments

Comments
 (0)