Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dde66e0

Browse files
squash some warnings
1 parent 0895a28 commit dde66e0

File tree

2 files changed

+30
-36
lines changed

2 files changed

+30
-36
lines changed

‎hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveSessionImpl.java‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ public <T> CompletionStage<T> reactiveFetch(T association, boolean unproxy) {
273273
return nullFuture();
274274
}
275275

276-
if ( association instanceof HibernateProxy ) {
277-
LazyInitializer initializer = ( (HibernateProxy) association ).getHibernateLazyInitializer();
276+
if ( association instanceof HibernateProxy proxy) {
277+
LazyInitializer initializer = proxy.getHibernateLazyInitializer();
278278
if ( !initializer.isUninitialized() ) {
279279
return completedFuture( unproxy ? (T) initializer.getImplementation() : association );
280280
}
@@ -290,13 +290,12 @@ public <T> CompletionStage<T> reactiveFetch(T association, boolean unproxy) {
290290
} );
291291
}
292292
}
293-
else if ( association instanceof PersistentCollection ) {
294-
final PersistentCollection<?> persistentCollection = (PersistentCollection<?>) association;
295-
if ( persistentCollection.wasInitialized() ) {
293+
else if (association instanceof PersistentCollection<?> collection) {
294+
if ( collection.wasInitialized() ) {
296295
return completedFuture( association );
297296
}
298297
else {
299-
return reactiveInitializeCollection( persistentCollection, false )
298+
return reactiveInitializeCollection( collection, false )
300299
// don't reassociate the collection instance, because
301300
// its owner isn't associated with this session
302301
.thenApply( v -> association );
@@ -305,9 +304,8 @@ else if ( association instanceof PersistentCollection ) {
305304
else if ( isPersistentAttributeInterceptable( association ) ) {
306305
final PersistentAttributeInterceptable interceptable = asPersistentAttributeInterceptable( association );
307306
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
308-
if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
309-
EnhancementAsProxyLazinessInterceptor eapli = (EnhancementAsProxyLazinessInterceptor) interceptor;
310-
return forceInitialize( association, null, eapli.getIdentifier(), eapli.getEntityName(), this )
307+
if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor lazinessInterceptor ) {
308+
return forceInitialize( association, null, lazinessInterceptor.getIdentifier(), lazinessInterceptor.getEntityName(), this )
311309
.thenApply( i -> association );
312310

313311
}
@@ -369,7 +367,7 @@ public <R> ReactiveQuery<R> createReactiveQuery(String queryString, Class<R> exp
369367
delayedAfterCompletion();
370368

371369
try {
372-
final HqlInterpretation interpretation = interpretHql( queryString, expectedResultType );
370+
final HqlInterpretation<?> interpretation = interpretHql( queryString, expectedResultType );
373371
final ReactiveQuerySqmImpl<R> query =
374372
new ReactiveQuerySqmImpl<>( queryString, interpretation, expectedResultType, this );
375373
applyQuerySettingsAndHints( query );
@@ -482,7 +480,7 @@ private <R> ReactiveSelectionQuery<R> interpretAndCreateSelectionQuery(String hq
482480
delayedAfterCompletion();
483481

484482
try {
485-
final HqlInterpretation interpretation = interpretHql( hql, resultType );
483+
final HqlInterpretation<?> interpretation = interpretHql( hql, resultType );
486484
checkSelectionQuery( hql, interpretation );
487485
return createSelectionQuery( hql, resultType, interpretation );
488486
}
@@ -492,7 +490,7 @@ private <R> ReactiveSelectionQuery<R> interpretAndCreateSelectionQuery(String hq
492490
}
493491
}
494492

495-
private <R> ReactiveSelectionQuery<R> createSelectionQuery(String hql, Class<R> resultType, HqlInterpretation interpretation) {
493+
private <R> ReactiveSelectionQuery<R> createSelectionQuery(String hql, Class<R> resultType, HqlInterpretation<?> interpretation) {
496494
final ReactiveSqmSelectionQueryImpl<R> query =
497495
new ReactiveSqmSelectionQueryImpl<>( hql, interpretation, resultType, this );
498496
if ( resultType != null ) {
@@ -1671,9 +1669,8 @@ public void setBatchSize(Integer batchSize) {
16711669
@Override
16721670
@SuppressWarnings("unchecked")
16731671
public <T> Class<T> getEntityClass(T entity) {
1674-
if ( entity instanceof HibernateProxy ) {
1675-
return (Class<T>) ( (HibernateProxy) entity )
1676-
.getHibernateLazyInitializer()
1672+
if ( entity instanceof HibernateProxy proxy ) {
1673+
return (Class<T>) proxy.getHibernateLazyInitializer()
16771674
.getPersistentClass();
16781675
}
16791676
else {
@@ -1684,8 +1681,8 @@ public <T> Class<T> getEntityClass(T entity) {
16841681

16851682
@Override
16861683
public Object getEntityId(Object entity) {
1687-
if ( entity instanceof HibernateProxy ) {
1688-
return ( (HibernateProxy) entity ).getHibernateLazyInitializer()
1684+
if ( entity instanceof HibernateProxy proxy) {
1685+
return proxy.getHibernateLazyInitializer()
16891686
.getIdentifier();
16901687
}
16911688
else {

‎hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveStatelessSessionImpl.java‎

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ public CompletionStage<Void> reactiveDelete(Object entity) {
397397
@Override
398398
public CompletionStage<Void> reactiveUpdate(Object entity) {
399399
checkOpen();
400-
if ( entity instanceof HibernateProxy ) {
401-
final LazyInitializer hibernateLazyInitializer = ( (HibernateProxy) entity ).getHibernateLazyInitializer();
400+
if ( entity instanceof HibernateProxy proxy) {
401+
final LazyInitializer hibernateLazyInitializer = proxy.getHibernateLazyInitializer();
402402
return hibernateLazyInitializer.isUninitialized()
403403
? failedFuture( LOG.uninitializedProxyUpdate( entity.getClass() ) )
404404
: executeReactiveUpdate( hibernateLazyInitializer.getImplementation() );
@@ -730,22 +730,21 @@ public <T> CompletionStage<T> reactiveFetch(T association, boolean unproxy) {
730730
return completedFuture( unproxy ? (T) initializer.getImplementation() : association );
731731
}
732732
}
733-
else if ( association instanceof PersistentCollection ) {
734-
final PersistentCollection<?> persistentCollection = (PersistentCollection<?>) association;
735-
if ( persistentCollection.wasInitialized() ) {
733+
else if ( association instanceof PersistentCollection<?> collection ) {
734+
if ( collection.wasInitialized() ) {
736735
return completedFuture( association );
737736
}
738737
else {
739738
final ReactiveCollectionPersister collectionDescriptor =
740739
(ReactiveCollectionPersister) getFactory().getMappingMetamodel()
741-
.getCollectionDescriptor( persistentCollection.getRole() );
740+
.getCollectionDescriptor( collection.getRole() );
742741

743-
final Object key = persistentCollection.getKey();
744-
persistenceContext.addUninitializedCollection( collectionDescriptor, persistentCollection, key );
745-
persistentCollection.setCurrentSession( this );
742+
final Object key = collection.getKey();
743+
persistenceContext.addUninitializedCollection( collectionDescriptor, collection, key );
744+
collection.setCurrentSession( this );
746745
return collectionDescriptor.reactiveInitialize( key, this )
747746
.whenComplete( (v, e) -> {
748-
persistentCollection.unsetSession( this );
747+
collection.unsetSession( this );
749748
if ( persistenceContext.isLoadFinished() ) {
750749
persistenceContext.clear();
751750
}
@@ -756,13 +755,11 @@ else if ( association instanceof PersistentCollection ) {
756755
else if ( isPersistentAttributeInterceptable( association ) ) {
757756
final PersistentAttributeInterceptable interceptable = asPersistentAttributeInterceptable( association );
758757
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
759-
if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
760-
final EnhancementAsProxyLazinessInterceptor proxyInterceptor =
761-
(EnhancementAsProxyLazinessInterceptor) interceptor;
762-
proxyInterceptor.setSession( this );
763-
return forceInitialize( association, null, proxyInterceptor.getIdentifier(), proxyInterceptor.getEntityName(), this )
758+
if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor lazinessInterceptor ) {
759+
lazinessInterceptor.setSession( this );
760+
return forceInitialize( association, null, lazinessInterceptor.getIdentifier(), lazinessInterceptor.getEntityName(), this )
764761
.whenComplete( (i,e) -> {
765-
proxyInterceptor.unsetSession();
762+
lazinessInterceptor.unsetSession();
766763
if ( persistenceContext.isLoadFinished() ) {
767764
persistenceContext.clear();
768765
}
@@ -860,7 +857,7 @@ public <R> ReactiveSqmQueryImplementor<R> createReactiveQuery(String queryString
860857
delayedAfterCompletion();
861858

862859
try {
863-
final HqlInterpretation interpretation = interpretHql( queryString, expectedResultType );
860+
final HqlInterpretation<?> interpretation = interpretHql( queryString, expectedResultType );
864861
final ReactiveQuerySqmImpl<R> query =
865862
new ReactiveQuerySqmImpl<>( queryString, interpretation, expectedResultType, this );
866863
applyQuerySettingsAndHints( query );
@@ -973,7 +970,7 @@ private <R> ReactiveSelectionQuery<R> interpretAndCreateSelectionQuery(String hq
973970
delayedAfterCompletion();
974971

975972
try {
976-
final HqlInterpretation interpretation = interpretHql( hql, resultType );
973+
final HqlInterpretation<?> interpretation = interpretHql( hql, resultType );
977974
checkSelectionQuery( hql, interpretation );
978975
return createSelectionQuery( hql, resultType, interpretation );
979976
}
@@ -983,7 +980,7 @@ private <R> ReactiveSelectionQuery<R> interpretAndCreateSelectionQuery(String hq
983980
}
984981
}
985982

986-
private <R> ReactiveSelectionQuery<R> createSelectionQuery(String hql, Class<R> resultType, HqlInterpretation interpretation) {
983+
private <R> ReactiveSelectionQuery<R> createSelectionQuery(String hql, Class<R> resultType, HqlInterpretation<?> interpretation) {
987984
final ReactiveSqmSelectionQueryImpl<R> query =
988985
new ReactiveSqmSelectionQueryImpl<>( hql, interpretation, resultType, this );
989986
if ( resultType != null ) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /