while ( tables.hasNext() ) {
synchronizedTables.add( ( (Element) tables.next() ).attributeValue( "table" ) );
}
boolean callable = "true".equals( queryElem.attributeValue( "callable" ) );
NamedSQLQueryDefinition namedQuery;
Attribute ref = queryElem.attribute( "resultset-ref" );
String resultSetRef = ref == null ? null : ref.getValue();
if ( StringHelper.isNotEmpty( resultSetRef ) ) {
namedQuery = new NamedSQLQueryDefinition(
queryElem.getText(),
resultSetRef,
synchronizedTables,
cacheable,
region,
timeout,
fetchSize,
HbmBinder.getFlushMode( queryElem.attributeValue( "flush-mode" ) ),
HbmBinder.getCacheMode( cacheMode ),
readOnly,
comment,
HbmBinder.getParameterTypes( queryElem ),
callable
);
//TODO check there is no actual definition elemnents when a ref is defined
}
else {
ResultSetMappingDefinition definition = buildResultSetMappingDefinition( queryElem, path, mappings );
namedQuery = new NamedSQLQueryDefinition(
queryElem.getText(),
definition.getQueryReturns(),
synchronizedTables,
cacheable,
region,
timeout,
fetchSize,
HbmBinder.getFlushMode( queryElem.attributeValue( "flush-mode" ) ),
HbmBinder.getCacheMode( cacheMode ),
readOnly,
comment,
HbmBinder.getParameterTypes( queryElem ),
callable
);
}
log.debug( "Named SQL query: " + queryName + " -> " + namedQuery.getQueryString() );
mappings.addSQLQuery( queryName, namedQuery );
}