HHH-2188 Query metadata gives NPE for polymorphic queries

Conflicts:
	hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java
This commit is contained in:
Brett Meyer 2014-01-10 14:14:17 -05:00
parent 24c951a3d1
commit 4a57b45958
1 changed files with 11 additions and 10 deletions

View File

@ -40,11 +40,10 @@ 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;
import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.Cache; import org.hibernate.Cache;
import org.hibernate.ConnectionReleaseMode; import org.hibernate.ConnectionReleaseMode;
@ -62,8 +61,6 @@ import org.hibernate.SessionBuilder;
import org.hibernate.SessionEventListener; import org.hibernate.SessionEventListener;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.SessionFactoryObserver; import org.hibernate.SessionFactoryObserver;
import org.hibernate.engine.spi.CacheImplementor;
import org.hibernate.engine.spi.SessionOwner;
import org.hibernate.StatelessSession; import org.hibernate.StatelessSession;
import org.hibernate.StatelessSessionBuilder; import org.hibernate.StatelessSessionBuilder;
import org.hibernate.TypeHelper; import org.hibernate.TypeHelper;
@ -101,13 +98,16 @@ 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.query.spi.sql.NativeSQLQuerySpecification; import org.hibernate.engine.query.spi.sql.NativeSQLQuerySpecification;
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;
import org.hibernate.engine.spi.NamedQueryDefinition; import org.hibernate.engine.spi.NamedQueryDefinition;
import org.hibernate.engine.spi.NamedSQLQueryDefinition; import org.hibernate.engine.spi.NamedSQLQueryDefinition;
import org.hibernate.engine.spi.SessionBuilderImplementor; import org.hibernate.engine.spi.SessionBuilderImplementor;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionOwner;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.spi.TransactionEnvironment; import org.hibernate.engine.transaction.spi.TransactionEnvironment;
import org.hibernate.exception.spi.SQLExceptionConverter; import org.hibernate.exception.spi.SQLExceptionConverter;
@ -151,6 +151,7 @@ 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;
/** /**
@ -1233,15 +1234,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 {