43
43
import org .hibernate .dialect .lock .LockingStrategy ;
44
44
import org .hibernate .engine .FetchTiming ;
45
45
import org .hibernate .engine .OptimisticLockStyle ;
46
- import org .hibernate .engine .internal .CacheHelper ;
47
46
import org .hibernate .engine .internal .ImmutableEntityEntryFactory ;
48
47
import org .hibernate .engine .internal .MutableEntityEntryFactory ;
49
48
import org .hibernate .engine .profile .internal .FetchProfileAffectee ;
68
67
import org .hibernate .generator .internal .VersionGeneration ;
69
68
import org .hibernate .generator .values .GeneratedValues ;
70
69
import org .hibernate .generator .values .GeneratedValuesMutationDelegate ;
71
- import org .hibernate .generator .values .internal .GeneratedValuesHelper ;
72
70
import org .hibernate .id .BulkInsertionCapableIdentifierGenerator ;
73
71
import org .hibernate .id .IdentifierGenerator ;
74
72
import org .hibernate .id .OptimizableGenerator ;
257
255
import static java .util .Collections .emptySet ;
258
256
import static java .util .Collections .unmodifiableList ;
259
257
import static org .hibernate .boot .model .internal .SoftDeleteHelper .resolveSoftDeleteMapping ;
258
+ import static org .hibernate .engine .internal .CacheHelper .fromSharedCache ;
260
259
import static org .hibernate .engine .internal .ManagedTypeHelper .asPersistentAttributeInterceptable ;
261
260
import static org .hibernate .engine .internal .ManagedTypeHelper .isPersistentAttributeInterceptable ;
262
261
import static org .hibernate .engine .internal .ManagedTypeHelper .processIfPersistentAttributeInterceptable ;
263
262
import static org .hibernate .generator .EventType .FORCE_INCREMENT ;
264
263
import static org .hibernate .generator .EventType .INSERT ;
265
264
import static org .hibernate .generator .EventType .UPDATE ;
265
+ import static org .hibernate .generator .values .internal .GeneratedValuesHelper .getGeneratedValuesDelegate ;
266
266
import static org .hibernate .internal .util .ReflectHelper .isAbstractClass ;
267
267
import static org .hibernate .internal .util .StringHelper .isEmpty ;
268
268
import static org .hibernate .internal .util .StringHelper .qualify ;
284
284
import static org .hibernate .internal .util .collections .CollectionHelper .toSmallList ;
285
285
import static org .hibernate .loader .ast .internal .MultiKeyLoadHelper .supportsSqlArrayType ;
286
286
import static org .hibernate .metamodel .RepresentationMode .POJO ;
287
+ import static org .hibernate .metamodel .mapping .internal .GeneratedValuesProcessor .getGeneratedAttributes ;
287
288
import static org .hibernate .metamodel .mapping .internal .MappingModelCreationHelper .buildBasicAttributeMapping ;
288
289
import static org .hibernate .metamodel .mapping .internal .MappingModelCreationHelper .buildEncapsulatedCompositeIdentifierMapping ;
289
290
import static org .hibernate .metamodel .mapping .internal .MappingModelCreationHelper .buildNonEncapsulatedCompositeIdentifierMapping ;
@@ -667,25 +668,25 @@ else if ( selectable instanceof Column column ) {
667
668
names .add ( prop .getName () );
668
669
types .add ( prop .getType () );
669
670
670
- final String [] cols = new String [ prop .getColumnSpan () ];
671
- final String [] readers = new String [ prop .getColumnSpan () ];
672
- final String [] readerTemplates = new String [ prop .getColumnSpan () ];
673
- final String [] forms = new String [ prop .getColumnSpan () ];
671
+ final int columnSpan = prop .getColumnSpan ();
672
+ final String [] columnNames = new String [columnSpan ];
673
+ final String [] readers = new String [columnSpan ];
674
+ final String [] readerTemplates = new String [columnSpan ];
675
+ final String [] formulaTemplates = new String [columnSpan ];
674
676
675
677
final var selectables = prop .getSelectables ();
676
678
for ( int i = 0 ; i < selectables .size (); i ++ ) {
677
679
final var selectable = selectables .get (i );
678
680
if ( selectable instanceof Formula ) {
679
- final String template = selectable .getTemplate ( dialect , typeConfiguration );
680
- forms [i ] = template ;
681
+ formulaTemplates [i ] = selectable .getTemplate ( dialect , typeConfiguration );
681
682
final String formulaAlias = selectable .getAlias ( dialect );
682
683
if ( prop .isSelectable () && !formulaAliases .contains ( formulaAlias ) ) {
683
684
formulaAliases .add ( formulaAlias );
684
685
}
685
686
}
686
687
else if ( selectable instanceof Column column ) {
687
- final String colName = column .getQuotedName (dialect );
688
- cols [i ] = colName ;
688
+ final String quotedColumnName = column .getQuotedName (dialect );
689
+ columnNames [i ] = quotedColumnName ;
689
690
final String columnAlias = selectable .getAlias ( dialect , prop .getValue ().getTable () );
690
691
if ( prop .isSelectable () && !aliases .contains ( columnAlias ) ) {
691
692
aliases .add ( columnAlias );
@@ -695,14 +696,14 @@ else if ( selectable instanceof Column column ) {
695
696
if ( thisClassProperties .contains ( prop )
696
697
? persistentClass .hasSubclasses ()
697
698
: persistentClass .isDefinedOnMultipleSubclasses ( column ) ) {
698
- sharedColumnNames .add ( colName );
699
+ sharedColumnNames .add ( quotedColumnName );
699
700
}
700
701
}
701
702
}
702
- propColumns .add ( cols );
703
+ propColumns .add ( columnNames );
703
704
propColumnReaders .add ( readers );
704
705
propColumnReaderTemplates .add ( readerTemplates );
705
- templates .add ( forms );
706
+ templates .add ( formulaTemplates );
706
707
707
708
joinedFetchesList .add ( prop .getValue ().getFetchMode () );
708
709
}
@@ -1470,7 +1471,7 @@ && isLazyPropertiesCacheable() ) {
1470
1471
session .getFactory (),
1471
1472
session .getTenantIdentifier ()
1472
1473
);
1473
- final Object structuredEntry = CacheHelper . fromSharedCache ( session , cacheKey , this , cacheAccess );
1474
+ final Object structuredEntry = fromSharedCache ( session , cacheKey , this , cacheAccess );
1474
1475
if ( structuredEntry != null ) {
1475
1476
final var cacheEntry = (CacheEntry ) getCacheEntryStructure ().destructure ( structuredEntry , factory );
1476
1477
final Object initializedValue = initializeLazyPropertiesFromCache ( fieldName , entity , session , entry , cacheEntry );
@@ -3131,24 +3132,25 @@ protected boolean shouldInnerJoinSubclassTable(int subclassTableNumber, Set<Stri
3131
3132
return !isInverseTable ( subclassTableNumber )
3132
3133
&& !isNullableTable ( subclassTableNumber );
3133
3134
}
3134
-
3135
- // otherwise we have a subclass table and need to look a little deeper...
3136
-
3137
- // IMPL NOTE: By default, 'includeSubclasses' indicates that all subclasses should be joined and that each
3138
- // subclass ought to be joined by outer join. However, 'TREAT AS' always requires that an inner join be used,
3139
- // so we give 'TREAT AS' higher precedence...
3140
-
3141
- return isSubclassTableIndicatedByTreatAsDeclarations ( subclassTableNumber , treatAsDeclarations );
3135
+ else {
3136
+ // otherwise we have a subclass table and need to look a little deeper...
3137
+ // IMPL NOTE: By default, 'includeSubclasses' indicates that all subclasses should be joined and that
3138
+ // each subclass ought to be joined by outer join. However, 'TREAT AS' always requires that an inner
3139
+ // join be used, so we give 'TREAT AS' higher precedence.
3140
+ return isSubclassTableIndicatedByTreatAsDeclarations ( subclassTableNumber , treatAsDeclarations );
3141
+ }
3142
3142
}
3143
3143
3144
3144
protected boolean isSubclassTableIndicatedByTreatAsDeclarations (int subclassTableNumber , Set <String > treatAsDeclarations ) {
3145
3145
return false ;
3146
3146
}
3147
3147
3148
3148
/**
3149
- * Post-construct is a callback for AbstractEntityPersister subclasses to call after they are all done with their
3150
- * constructor processing. It allows AbstractEntityPersister to extend its construction after all subclass-specific
3151
- * details have been handled.
3149
+ * Post-construct is a callback for {@code AbstractEntityPersister}
3150
+ * subclasses to call after they are all done with their constructor
3151
+ * processing. It allows {@code AbstractEntityPersister} to extend
3152
+ * its construction after subclass-specific details have all been
3153
+ * taken care of.
3152
3154
*
3153
3155
* @param mapping The mapping
3154
3156
*
@@ -3174,11 +3176,11 @@ private void doLateInit() {
3174
3176
3175
3177
final List <AttributeMapping > insertGeneratedAttributes =
3176
3178
hasInsertGeneratedProperties ()
3177
- ? GeneratedValuesProcessor . getGeneratedAttributes ( this , INSERT )
3179
+ ? getGeneratedAttributes ( this , INSERT )
3178
3180
: emptyList ();
3179
3181
final List <AttributeMapping > updateGeneratedAttributes =
3180
3182
hasUpdateGeneratedProperties ()
3181
- ? GeneratedValuesProcessor . getGeneratedAttributes ( this , UPDATE )
3183
+ ? getGeneratedAttributes ( this , UPDATE )
3182
3184
: emptyList ();
3183
3185
3184
3186
insertGeneratedProperties = initInsertGeneratedProperties ( insertGeneratedAttributes );
@@ -3192,10 +3194,12 @@ private void doLateInit() {
3192
3194
}
3193
3195
3194
3196
if ( hasInsertGeneratedProperties () ) {
3195
- insertGeneratedValuesProcessor = createGeneratedValuesProcessor ( INSERT , insertGeneratedAttributes );
3197
+ insertGeneratedValuesProcessor =
3198
+ createGeneratedValuesProcessor ( INSERT , insertGeneratedAttributes );
3196
3199
}
3197
3200
if ( hasUpdateGeneratedProperties () ) {
3198
- updateGeneratedValuesProcessor = createGeneratedValuesProcessor ( UPDATE , updateGeneratedAttributes );
3201
+ updateGeneratedValuesProcessor =
3202
+ createGeneratedValuesProcessor ( UPDATE , updateGeneratedAttributes );
3199
3203
}
3200
3204
3201
3205
insertCoordinator = buildInsertCoordinator ();
@@ -3212,11 +3216,11 @@ protected GeneratedValuesMutationDelegate createInsertDelegate() {
3212
3216
final var generator = (OnExecutionGenerator ) getGenerator ();
3213
3217
return generator .getGeneratedIdentifierDelegate ( this );
3214
3218
}
3215
- return GeneratedValuesHelper . getGeneratedValuesDelegate ( this , INSERT );
3219
+ return getGeneratedValuesDelegate ( this , INSERT );
3216
3220
}
3217
3221
3218
3222
protected GeneratedValuesMutationDelegate createUpdateDelegate () {
3219
- return GeneratedValuesHelper . getGeneratedValuesDelegate ( this , UPDATE );
3223
+ return getGeneratedValuesDelegate ( this , UPDATE );
3220
3224
}
3221
3225
3222
3226
private static class TableMappingBuilder {
@@ -3378,12 +3382,12 @@ protected EntityTableMapping[] buildTableMappings() {
3378
3382
}
3379
3383
} );
3380
3384
3381
- final EntityTableMapping [] list = new EntityTableMapping [tableBuilderMap .size ()];
3385
+ final var entityTableMappings = new EntityTableMapping [tableBuilderMap .size ()];
3382
3386
int i = 0 ;
3383
- for ( Map . Entry < String , TableMappingBuilder > entry : tableBuilderMap .entrySet () ) {
3384
- list [i ++] = entry .getValue ().build ();
3387
+ for ( var entry : tableBuilderMap .entrySet () ) {
3388
+ entityTableMappings [i ++] = entry .getValue ().build ();
3385
3389
}
3386
- return list ;
3390
+ return entityTableMappings ;
3387
3391
}
3388
3392
3389
3393
/**
@@ -3427,8 +3431,7 @@ protected InsertCoordinator buildInsertCoordinator() {
3427
3431
protected UpdateCoordinator buildUpdateCoordinator () {
3428
3432
// we only have updates to issue for entities with one or more singular attributes
3429
3433
for ( int i = 0 ; i < attributeMappings .size (); i ++ ) {
3430
- final AttributeMapping attributeMapping = attributeMappings .get ( i );
3431
- if ( attributeMapping instanceof SingularAttributeMapping ) {
3434
+ if ( attributeMappings .get ( i ) instanceof SingularAttributeMapping ) {
3432
3435
return new UpdateCoordinatorStandard ( this , factory );
3433
3436
}
3434
3437
}
@@ -3439,8 +3442,7 @@ protected UpdateCoordinator buildUpdateCoordinator() {
3439
3442
protected UpdateCoordinator buildMergeCoordinator () {
3440
3443
// we only have updates to issue for entities with one or more singular attributes
3441
3444
for ( int i = 0 ; i < attributeMappings .size (); i ++ ) {
3442
- final AttributeMapping attributeMapping = attributeMappings .get ( i );
3443
- if ( attributeMapping instanceof SingularAttributeMapping ) {
3445
+ if ( attributeMappings .get ( i ) instanceof SingularAttributeMapping ) {
3444
3446
return new MergeCoordinator ( this , factory );
3445
3447
}
3446
3448
}
@@ -3449,12 +3451,9 @@ protected UpdateCoordinator buildMergeCoordinator() {
3449
3451
}
3450
3452
3451
3453
protected DeleteCoordinator buildDeleteCoordinator () {
3452
- if ( softDeleteMapping == null ) {
3453
- return new DeleteCoordinatorStandard ( this , factory );
3454
- }
3455
- else {
3456
- return new DeleteCoordinatorSoft ( this , factory );
3457
- }
3454
+ return softDeleteMapping == null
3455
+ ? new DeleteCoordinatorStandard ( this , factory )
3456
+ : new DeleteCoordinatorSoft ( this , factory );
3458
3457
}
3459
3458
3460
3459
@ Override
@@ -3523,7 +3522,7 @@ protected SingleIdEntityLoader<?> determineLoaderToUse(SharedSessionContractImpl
3523
3522
return getSingleIdLoader ();
3524
3523
}
3525
3524
3526
- final LoadQueryInfluencers influencers = session .getLoadQueryInfluencers ();
3525
+ final var influencers = session .getLoadQueryInfluencers ();
3527
3526
if ( isAffectedByInfluencers ( influencers , true ) ) {
3528
3527
return buildSingleIdEntityLoader ( influencers , lockOptions );
3529
3528
}
@@ -3877,15 +3876,14 @@ public Boolean isTransient(Object entity, SharedSessionContractImplementor sessi
3877
3876
if ( persistenceContext .hasLoadContext ()
3878
3877
&& !persistenceContext .getLoadContexts ().isLoadingFinished () ) {
3879
3878
// check if we're currently loading this entity instance, the version
3880
- // will be null but the entity cannot be considered transient
3879
+ // will be null, but the entity cannot be considered transient
3881
3880
final var holder = persistenceContext .getEntityHolder ( new EntityKey ( id , this ) );
3882
3881
if ( holder != null && holder .isEventuallyInitialized () && holder .getEntity () == entity ) {
3883
3882
return false ;
3884
3883
}
3885
3884
}
3886
3885
}
3887
- final var identifierGenerator = getGenerator ();
3888
- if ( identifierGenerator != null ) {
3886
+ if ( getGenerator () != null ) {
3889
3887
final Boolean unsaved = identifierMapping .getUnsavedStrategy ().isUnsaved ( id );
3890
3888
if ( unsaved != null && !unsaved ) {
3891
3889
throw new PropertyValueException (
@@ -3909,10 +3907,10 @@ public Boolean isTransient(Object entity, SharedSessionContractImplementor sessi
3909
3907
3910
3908
// check to see if it is in the second-level cache
3911
3909
if ( session .getCacheMode ().isGetEnabled () && canReadFromCache () ) {
3912
- final var cache = getCacheAccessStrategy ();
3913
3910
final Object cacheKey =
3914
- cache .generateCacheKey ( id , this , session .getFactory (), session .getTenantIdentifier () );
3915
- final Object cacheEntry = CacheHelper .fromSharedCache ( session , cacheKey , this , getCacheAccessStrategy () );
3911
+ getCacheAccessStrategy ()
3912
+ .generateCacheKey ( id , this , session .getFactory (), session .getTenantIdentifier () );
3913
+ final Object cacheEntry = fromSharedCache ( session , cacheKey , this , getCacheAccessStrategy () );
3916
3914
if ( cacheEntry != null ) {
3917
3915
return false ;
3918
3916
}
0 commit comments