|
11 | 11 | import jakarta.persistence.EntityGraph;
|
12 | 12 | import jakarta.persistence.FlushModeType;
|
13 | 13 | import jakarta.persistence.LockModeType;
|
| 14 | +import jakarta.persistence.PersistenceException; |
14 | 15 | import jakarta.persistence.criteria.CriteriaDelete;
|
15 | 16 | import jakarta.persistence.criteria.CriteriaQuery;
|
16 | 17 | import jakarta.persistence.criteria.CriteriaUpdate;
|
|
24 | 25 | import org.hibernate.reactive.common.AffectedEntities;
|
25 | 26 | import org.hibernate.reactive.common.Identifier;
|
26 | 27 | import org.hibernate.reactive.common.ResultSetMapping;
|
| 28 | +import org.hibernate.reactive.engine.spi.ReactiveSharedSessionContractImplementor; |
27 | 29 | import org.hibernate.reactive.logging.impl.Log;
|
28 | 30 | import org.hibernate.reactive.logging.impl.LoggerFactory;
|
29 | 31 | import org.hibernate.reactive.mutiny.Mutiny;
|
|
32 | 34 | import org.hibernate.reactive.mutiny.Mutiny.SelectionQuery;
|
33 | 35 | import org.hibernate.reactive.pool.ReactiveConnection;
|
34 | 36 | import org.hibernate.reactive.query.sqm.iternal.ReactiveQuerySqmImpl;
|
| 37 | +import org.hibernate.reactive.session.ReactiveConnectionSupplier; |
| 38 | +import org.hibernate.reactive.session.ReactiveQueryProducer; |
35 | 39 | import org.hibernate.reactive.session.ReactiveSession;
|
36 | 40 |
|
37 | 41 | import java.lang.invoke.MethodHandles;
|
@@ -538,4 +542,21 @@ public <T> EntityGraph<T> createEntityGraph(Class<T> rootType) {
|
538 | 542 | public <T> EntityGraph<T> createEntityGraph(Class<T> rootType, String graphName) {
|
539 | 543 | return delegate.createEntityGraph( rootType, graphName );
|
540 | 544 | }
|
| 545 | + |
| 546 | + public <T> T unwrap(Class<T> clazz) { |
| 547 | + if ( ReactiveConnectionSupplier.class.isAssignableFrom( clazz ) ) { |
| 548 | + return clazz.cast( this.delegate ); |
| 549 | + } |
| 550 | + else if ( ReactiveSession.class.isAssignableFrom( clazz ) ) { |
| 551 | + return clazz.cast( this.delegate ); |
| 552 | + } |
| 553 | + else if ( ReactiveQueryProducer.class.isAssignableFrom( clazz ) ) { |
| 554 | + return clazz.cast( this.delegate ); |
| 555 | + } |
| 556 | + else if ( ReactiveSharedSessionContractImplementor.class.isAssignableFrom( clazz ) ) { |
| 557 | + return clazz.cast( this.delegate ); |
| 558 | + } |
| 559 | + throw new PersistenceException( "Cannot unwrap type " + clazz ); |
| 560 | + } |
| 561 | + |
541 | 562 | }
|
0 commit comments