diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index cc58b8be20..ef691d4f25 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -40,6 +40,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; + import javax.naming.Reference; import javax.naming.StringRefAddr; @@ -104,6 +105,7 @@ import org.hibernate.engine.profile.Association; import org.hibernate.engine.profile.Fetch; import org.hibernate.engine.profile.FetchProfile; import org.hibernate.engine.query.spi.QueryPlanCache; +import org.hibernate.engine.query.spi.ReturnMetadata; import org.hibernate.engine.spi.CacheImplementor; import org.hibernate.engine.spi.FilterDefinition; import org.hibernate.engine.spi.Mapping; @@ -151,7 +153,6 @@ import org.hibernate.tuple.entity.EntityTuplizer; import org.hibernate.type.AssociationType; import org.hibernate.type.Type; import org.hibernate.type.TypeResolver; - import org.jboss.logging.Logger; @@ -1195,15 +1196,15 @@ public final class SessionFactoryImpl } public Type[] getReturnTypes(String queryString) throws HibernateException { - return queryPlanCache.getHQLQueryPlan( queryString, false, Collections.EMPTY_MAP ) - .getReturnMetadata() - .getReturnTypes(); + final ReturnMetadata metadata = queryPlanCache.getHQLQueryPlan( queryString, false, Collections.EMPTY_MAP ) + .getReturnMetadata(); + return metadata == null ? null : metadata.getReturnTypes(); } public String[] getReturnAliases(String queryString) throws HibernateException { - return queryPlanCache.getHQLQueryPlan( queryString, false, Collections.EMPTY_MAP ) - .getReturnMetadata() - .getReturnAliases(); + final ReturnMetadata metadata = queryPlanCache.getHQLQueryPlan( queryString, false, Collections.EMPTY_MAP ) + .getReturnMetadata(); + return metadata == null ? null : metadata.getReturnAliases(); } public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException {