HHH-4412 Cleanup and copyrights

This commit is contained in:
Brett Meyer 2013-03-06 09:31:57 -05:00
parent 6cda7dc577
commit 31f43e3321
4 changed files with 81 additions and 41 deletions

View File

@ -114,26 +114,27 @@ 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();
NamedSQLQueryDefinitionBuilder builder = new NamedSQLQueryDefinitionBuilder( queryAnn.name() )
.setQuery( queryName )
.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 ) );
if ( !BinderHelper.isEmptyAnnotationValue( resultSetMapping ) ) {
//sql result set usage
query = new NamedSQLQueryDefinitionBuilder( queryAnn.name() )
.setQuery( queryName )
.setResultSetRef( resultSetMapping )
.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 ) )
builder.setResultSetRef( resultSetMapping )
.createNamedQueryDefinition();
}
else if ( !void.class.equals( queryAnn.resultClass() ) ) {
@ -141,35 +142,14 @@ public abstract class QueryBinder {
//FIXME should be done in a second pass due to entity name?
final NativeSQLQueryRootReturn entityQueryReturn =
new NativeSQLQueryRootReturn( "alias1", queryAnn.resultClass().getName(), new HashMap(), LockMode.READ );
query = new NamedSQLQueryDefinitionBuilder( queryAnn.name() )
.setQuery( queryName )
.setQueryReturns( new NativeSQLQueryReturn[] {entityQueryReturn} )
.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();
builder.setQueryReturns( new NativeSQLQueryReturn[] {entityQueryReturn} );
}
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();
builder.setQueryReturns( new NativeSQLQueryReturn[0] );
}
NamedSQLQueryDefinition query = builder.createNamedQueryDefinition();
if ( isDefault ) {
mappings.addDefaultSQLQuery( query.getName(), query );
}

View File

@ -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;

View File

@ -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;

View File

@ -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;