}
String resultSetMapping = queryAnn.resultSetMapping();
QueryHintDefinition hints = new QueryHintDefinition( queryAnn.hints() );
String queryName = queryAnn.query();
NamedSQLQueryDefinitionBuilder builder = new NamedSQLQueryDefinitionBuilder( queryAnn.name() )
.setQuery( queryName )
.setQuerySpaces( null )
.setCacheable( hints.getBoolean( queryName, QueryHints.CACHEABLE ) )
.setCacheRegion( hints.getString( queryName, QueryHints.CACHE_REGION ) )
.setTimeout( hints.getTimeout( queryName ) )
.setFetchSize( hints.getInteger( queryName, QueryHints.FETCH_SIZE ) )
.setFlushMode( hints.getFlushMode( queryName ) )
.setCacheMode( hints.getCacheMode( queryName ) )
.setReadOnly( hints.getBoolean( queryName, QueryHints.READ_ONLY ) )
.setComment( hints.getString( queryName, QueryHints.COMMENT ) )
.setParameterTypes( null )
.setCallable( hints.getBoolean( queryName, QueryHints.CALLABLE ) );
if ( !BinderHelper.isEmptyAnnotationValue( resultSetMapping ) ) {
//sql result set usage
builder.setResultSetRef( resultSetMapping )
.createNamedQueryDefinition();
}
else if ( !void.class.equals( queryAnn.resultClass() ) ) {
//class mapping usage
//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 );
builder.setQueryReturns( new NativeSQLQueryReturn[] {entityQueryReturn} );
}
else {
builder.setQueryReturns( new NativeSQLQueryReturn[0] );
}
NamedSQLQueryDefinition query = builder.createNamedQueryDefinition();
if ( isDefault ) {
mappings.addDefaultSQLQuery( query.getName(), query );
}
else {