HHH-2188 Query metadata gives NPE for polymorphic queries

This commit is contained in:
Brett Meyer 2014-01-10 14:13:24 -05:00
parent 9a9a95e104
commit 5963b6a4be
1 changed files with 8 additions and 7 deletions

View File

@ -40,6 +40,7 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import javax.naming.Reference; import javax.naming.Reference;
import javax.naming.StringRefAddr; 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.Fetch;
import org.hibernate.engine.profile.FetchProfile; import org.hibernate.engine.profile.FetchProfile;
import org.hibernate.engine.query.spi.QueryPlanCache; 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.CacheImplementor;
import org.hibernate.engine.spi.FilterDefinition; import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.engine.spi.Mapping; 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.AssociationType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.type.TypeResolver; import org.hibernate.type.TypeResolver;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
@ -1195,15 +1196,15 @@ public final class SessionFactoryImpl
} }
public Type[] getReturnTypes(String queryString) throws HibernateException { public Type[] getReturnTypes(String queryString) throws HibernateException {
return queryPlanCache.getHQLQueryPlan( queryString, false, Collections.EMPTY_MAP ) final ReturnMetadata metadata = queryPlanCache.getHQLQueryPlan( queryString, false, Collections.EMPTY_MAP )
.getReturnMetadata() .getReturnMetadata();
.getReturnTypes(); return metadata == null ? null : metadata.getReturnTypes();
} }
public String[] getReturnAliases(String queryString) throws HibernateException { public String[] getReturnAliases(String queryString) throws HibernateException {
return queryPlanCache.getHQLQueryPlan( queryString, false, Collections.EMPTY_MAP ) final ReturnMetadata metadata = queryPlanCache.getHQLQueryPlan( queryString, false, Collections.EMPTY_MAP )
.getReturnMetadata() .getReturnMetadata();
.getReturnAliases(); return metadata == null ? null : metadata.getReturnAliases();
} }
public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException { public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException {