private QueryImpl buildQueryFromName(String name, Class resultType) {
checkOpen();
final SessionFactoryImplementor sfi = entityManagerFactory.getSessionFactory();
final NamedQueryDefinition jpqlDefinition = sfi.getNamedQueryRepository().getNamedQueryDefinition( name );
if ( jpqlDefinition != null ) {
return createNamedJpqlQuery( jpqlDefinition, resultType );
}
final NamedSQLQueryDefinition nativeQueryDefinition = sfi.getNamedQueryRepository().getNamedSQLQueryDefinition( name );
if ( nativeQueryDefinition != null ) {
return createNamedSqlQuery( nativeQueryDefinition, resultType );
}
throw convert( new IllegalArgumentException( "No query defined for that name [" + name + "]" ) );
}