public Query createNamedQuery(String name) {
return buildQueryFromName( name, null );
}
private <T> TypedQuery<T> buildQueryFromName(String name, Class<T> resultType) {
OgmSessionFactory sessionFactory = (OgmSessionFactory) factory.getSessionFactory();
NamedQueryDefinition queryDefinition = sessionFactory.getNamedSQLQuery( name );
if ( queryDefinition == null ) {
queryDefinition = sessionFactory.getNamedQuery( name );
if ( queryDefinition == null ) {
throw new IllegalArgumentException( "Named query not found: " + name );
}
else {
return createNamedJpqlQuery( queryDefinition, resultType );