Re-applying commit for HHH-6304 missed during rebase of JPA 2.1 branch with master due to JPA package refactoring
This commit is contained in:
parent
30d8fdaa8b
commit
693185a8ac
|
@ -333,10 +333,21 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
// do the translation
|
// do the translation
|
||||||
org.hibernate.Query hqlQuery = getSession().createQuery( jpaqlString );
|
org.hibernate.Query hqlQuery = getSession().createQuery( jpaqlString );
|
||||||
|
|
||||||
|
resultClassChecking( resultClass, hqlQuery );
|
||||||
|
|
||||||
|
// finally, build/return the query instance
|
||||||
|
return new QueryImpl<T>( hqlQuery, this );
|
||||||
|
}
|
||||||
|
catch ( HibernateException he ) {
|
||||||
|
throw convert( he );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void resultClassChecking(Class resultClass, org.hibernate.Query hqlQuery) {
|
||||||
// make sure the query is a select -> HHH-7192
|
// make sure the query is a select -> HHH-7192
|
||||||
final SessionImplementor session = unwrap( SessionImplementor.class );
|
final SessionImplementor session = unwrap( SessionImplementor.class );
|
||||||
final HQLQueryPlan queryPlan = session.getFactory().getQueryPlanCache().getHQLQueryPlan(
|
final HQLQueryPlan queryPlan = session.getFactory().getQueryPlanCache().getHQLQueryPlan(
|
||||||
jpaqlString,
|
hqlQuery.getQueryString(),
|
||||||
false,
|
false,
|
||||||
session.getLoadQueryInfluencers().getEnabledFilters()
|
session.getLoadQueryInfluencers().getEnabledFilters()
|
||||||
);
|
);
|
||||||
|
@ -380,13 +391,6 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally, build/return the query instance
|
|
||||||
return new QueryImpl<T>( hqlQuery, this );
|
|
||||||
}
|
|
||||||
catch ( HibernateException he ) {
|
|
||||||
throw convert( he );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TupleBuilderTransformer extends BasicTransformerAdapter {
|
public static class TupleBuilderTransformer extends BasicTransformerAdapter {
|
||||||
|
@ -747,12 +751,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( namedQuery.getReturnTypes().length != 1 ) {
|
resultClassChecking( resultClass, namedQuery );
|
||||||
throw new IllegalArgumentException( "Cannot create TypedQuery for query with more than one return" );
|
|
||||||
}
|
|
||||||
if ( !resultClass.isAssignableFrom( namedQuery.getReturnTypes()[0].getReturnedClass() ) ) {
|
|
||||||
throw buildIncompatibleException( resultClass, namedQuery.getReturnTypes()[0].getReturnedClass() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new QueryImpl<T>( namedQuery, this );
|
return new QueryImpl<T>( namedQuery, this );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue