|
18 | 18 | import org.hibernate.LockMode;
|
19 | 19 | import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
|
20 | 20 | import org.hibernate.collection.spi.AbstractPersistentCollection;
|
21 |
| -import org.hibernate.collection.spi.PersistentCollection; |
22 | 21 | import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
23 | 22 | import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
24 | 23 | import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
@@ -2452,18 +2451,18 @@ static <T> Uni<T> fetch(T association) {
|
2452 | 2451 | }
|
2453 | 2452 |
|
2454 | 2453 | final SharedSessionContractImplementor session;
|
2455 |
| - if ( association instanceof HibernateProxy ) { |
2456 |
| - session = ( (HibernateProxy) association ).getHibernateLazyInitializer().getSession(); |
| 2454 | + if ( association instanceof HibernateProxy proxy ) { |
| 2455 | + session = proxy.getHibernateLazyInitializer().getSession(); |
2457 | 2456 | }
|
2458 |
| - else if ( association instanceof PersistentCollection ) { |
| 2457 | + else if ( association instanceof AbstractPersistentCollection<?> collection ) { |
2459 | 2458 | //this unfortunately doesn't work for stateless session because the session ref gets set to null
|
2460 |
| - session = ( (AbstractPersistentCollection<?>) association ).getSession(); |
| 2459 | + session = collection.getSession(); |
2461 | 2460 | }
|
2462 | 2461 | else if ( isPersistentAttributeInterceptable( association ) ) {
|
2463 | 2462 | final PersistentAttributeInterceptable interceptable = asPersistentAttributeInterceptable( association );
|
2464 | 2463 | final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
2465 |
| - if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) { |
2466 |
| - session = ( (EnhancementAsProxyLazinessInterceptor) interceptor ).getLinkedSession(); |
| 2464 | + if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor lazinessInterceptor ) { |
| 2465 | + session = lazinessInterceptor.getLinkedSession(); |
2467 | 2466 | }
|
2468 | 2467 | else {
|
2469 | 2468 | return Uni.createFrom().item( association );
|
|
0 commit comments