}
private List<Object> listOfArrays(SessionImplementor session, Iterator<Tuple> tuples) {
List<Object> results = new ArrayList<Object>();
while ( tuples.hasNext() ) {
Tuple tuple = tuples.next();
Object[] entry = null;
if ( !customQuery.getCustomQueryReturns().isEmpty() ) {
entry = new Object[customQuery.getCustomQueryReturns().size()];
int i = 0;
for ( Return queryReturn : customQuery.getCustomQueryReturns() ) {
ScalarReturn scalarReturn = (ScalarReturn) queryReturn;
Type type = scalarReturn.getType();
if ( type != null ) {
GridType gridType = typeTranslator.getType( type );
entry[i++] = gridType.nullSafeGet( tuple, scalarReturn.getColumnAlias(), session, null );
}
else {
entry[i++] = tuple.get( scalarReturn.getColumnAlias() );
}
}
}
else {
// TODO OGM-564 As a temporary work-around, retrieving the names from the actual result in case there
// are no query returns defined (no result mapping has been given for a native query). Actually we
// should drive this based on the selected columns as otherwise the order might not be correct and/or
// null values will not show up
entry = new Object[tuple.getColumnNames().size()];
int i = 0;
for ( String column : tuple.getColumnNames() ) {
entry[i++] = tuple.get( column );
}
}
if ( entry.length == 1 ) {
results.add( entry[0] );