|
7 | 7 | import jakarta.persistence.criteria.CriteriaQuery; |
8 | 8 | import jakarta.persistence.criteria.Root; |
9 | 9 | import org.hibernate.QueryException; |
| 10 | +import org.hibernate.engine.spi.SessionFactoryImplementor; |
10 | 11 | import org.hibernate.engine.spi.SharedSessionContractImplementor; |
11 | 12 | import org.hibernate.metamodel.model.domain.EntityDomainType; |
12 | 13 | import org.hibernate.query.IllegalSelectQueryException; |
@@ -50,14 +51,14 @@ public SelectionSpecificationImpl( |
50 | 51 | SharedSessionContractImplementor session) { |
51 | 52 | this.resultType = resultType; |
52 | 53 | this.session = session; |
53 | | - this.sqmStatement = resolveSqmTree( hql, resultType, session ); |
| 54 | + this.sqmStatement = resolveSqmTree( hql, resultType, session.getFactory() ); |
54 | 55 | this.sqmRoot = extractRoot( sqmStatement, resultType, hql ); |
55 | 56 | } |
56 | 57 |
|
57 | 58 | public SelectionSpecificationImpl( |
58 | 59 | Class<T> rootEntityType, |
59 | 60 | SharedSessionContractImplementor session) { |
60 | | - this( "from " + determineEntityName( rootEntityType, session ), rootEntityType, session ); |
| 61 | + this( "from " + determineEntityName( rootEntityType, session.getFactory() ), rootEntityType, session ); |
61 | 62 | } |
62 | 63 |
|
63 | 64 | public SelectionSpecificationImpl( |
@@ -124,8 +125,8 @@ public SelectionQuery<T> createQuery() { |
124 | 125 | private static <T> SqmSelectStatement<T> resolveSqmTree( |
125 | 126 | String hql, |
126 | 127 | Class<T> resultType, |
127 | | - SharedSessionContractImplementor session) { |
128 | | - final QueryEngine queryEngine = session.getFactory().getQueryEngine(); |
| 128 | + SessionFactoryImplementor sessionFactory) { |
| 129 | + final QueryEngine queryEngine = sessionFactory.getQueryEngine(); |
129 | 130 | final HqlInterpretation<T> hqlInterpretation = queryEngine |
130 | 131 | .getInterpretationCache() |
131 | 132 | .resolveHqlInterpretation( hql, resultType, queryEngine.getHqlTranslator() ); |
@@ -174,11 +175,10 @@ private SqmRoot<T> extractRoot(SqmSelectStatement<T> sqmStatement, Class<T> resu |
174 | 175 |
|
175 | 176 | private static String determineEntityName( |
176 | 177 | Class<?> rootEntityType, |
177 | | - SharedSessionContractImplementor session) { |
178 | | - final EntityDomainType<?> entityType = session |
179 | | - .getFactory() |
180 | | - .getJpaMetamodel() |
181 | | - .findEntityType( rootEntityType ); |
| 178 | + SessionFactoryImplementor sessionFactory) { |
| 179 | + final EntityDomainType<?> entityType = |
| 180 | + sessionFactory.getJpaMetamodel() |
| 181 | + .findEntityType( rootEntityType ); |
182 | 182 | if ( entityType == null ) { |
183 | 183 | return rootEntityType.getName(); |
184 | 184 | } |
|
0 commit comments