diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java index c2018e8c99..a69c12f20d 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java @@ -96,10 +96,12 @@ public abstract class QueryBinder { if ( BinderHelper.isEmptyAnnotationValue( queryAnn.name() ) ) { throw new AnnotationException( "A named query must have a name when used in class or package level" ); } - NamedSQLQueryDefinition query; String resultSetMapping = queryAnn.resultSetMapping(); QueryHint[] hints = queryAnn.hints(); String queryName = queryAnn.query(); + + NamedSQLQueryDefinition query; + if ( !BinderHelper.isEmptyAnnotationValue( resultSetMapping ) ) { //sql result set usage query = new NamedSQLQueryDefinition( @@ -142,18 +144,24 @@ public abstract class QueryBinder { ); } else { - query = new NamedSQLQueryDefinitionBuilder( queryAnn.name() ).setQuery( queryName ) - .setQueryReturns( new NativeSQLQueryReturn[0] ).setQuerySpaces( null ) - .setCacheable( getBoolean( queryName, "org.hibernate.cacheable", hints ) ) - .setCacheRegion( getString( queryName, "org.hibernate.cacheRegion", hints ) ) - .setTimeout( getTimeout( queryName, hints ) ) - .setFetchSize( getInteger( queryName, "org.hibernate.fetchSize", hints ) ) - .setFlushMode( getFlushMode( queryName, hints ) ).setCacheMode( getCacheMode( queryName, hints ) ) - .setReadOnly( getBoolean( queryName, "org.hibernate.readOnly", hints ) ) - .setComment( getString( queryName, "org.hibernate.comment", hints ) ).setParameterTypes( null ) - .setCallable( getBoolean( queryName, "org.hibernate.callable", hints ) ) - .createNamedQueryDefinition(); + query = new NamedSQLQueryDefinition( + queryAnn.name(), + queryName, + new NativeSQLQueryReturn[0], + null, + getBoolean( queryName, "org.hibernate.cacheable", hints ), + getString( queryName, "org.hibernate.cacheRegion", hints ), + getTimeout( queryName, hints ), + getInteger( queryName, "org.hibernate.fetchSize", hints ), + getFlushMode( queryName, hints ), + getCacheMode( queryName, hints ), + getBoolean( queryName, "org.hibernate.readOnly", hints ), + getString( queryName, "org.hibernate.comment", hints ), + null, + getBoolean( queryName, "org.hibernate.callable", hints ) + ); } + if ( isDefault ) { mappings.addDefaultSQLQuery( query.getName(), query ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/DestinationEntity.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/DestinationEntity.java index 8e0b6de952..72bdaf529b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/DestinationEntity.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/DestinationEntity.java @@ -1,3 +1,23 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ package org.hibernate.test.jpa.ql; import javax.persistence.Column; diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/FromEntity.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/FromEntity.java index a2d7fcd290..ffd305a82c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/FromEntity.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/FromEntity.java @@ -1,3 +1,23 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ package org.hibernate.test.jpa.ql; import javax.persistence.Column; diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/NamedNativeQueryTest.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/NamedNativeQueryTest.java index efd7c81618..9c7c4ab727 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/NamedNativeQueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/ql/NamedNativeQueryTest.java @@ -1,3 +1,23 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * JBoss, Home of Professional Open Source + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors + * as indicated by the @authors tag. All rights reserved. + * See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License, v. 2.1. + * This program is distributed in the hope that it will be useful, but WITHOUT A + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License, + * v.2.1 along with this distribution; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ package org.hibernate.test.jpa.ql; import static org.junit.Assert.assertEquals;