Source:
<code>private Set<String> findQueryReferencedTables(QueryNode query) { if ( !walker.getSessionFactoryHelper() .getFactory() .getSessionFactoryOptions() .isOmitJoinOfSuperclassTablesEnabled() ) { if ( LOG.isDebugEnabled() ) { LOG.debug( String.format( "Finding of query referenced tables is skipped because the feature is disabled. See %s", AvailableSettings.OMIT_JOIN_OF_SUPERCLASS_TABLES ) ); } return null; } if ( CollectionHelper.isNotEmpty( walker.getEnabledFilters() ) ) { LOG.debug( "Finding of query referenced tables is skipped because filters are enabled." ); return null; } if ( LOG.isDebugEnabled() ) { LOG.debug( TokenPrinters.REFERENCED_TABLES_PRINTER.showAsString( query, "Tables referenced from query nodes:" ) ); } Set<String> result = new HashSet<>(); collectReferencedTables( new ASTIterator( query ), result ); for (FromElement fromElement : (List<FromElement>) query.getFromClause().getFromElements()) { String role = fromElement.getRole(); if ( role != null ) { result.add( fromElement.getOrigin().getPropertyTableName(role.substring(role.lastIndexOf('.') + 1)) ); } AST withClauseAst = fromElement.getWithClauseAst(); if ( withClauseAst != null ) { collectReferencedTables( new ASTIterator( withClauseAst ), result ); } } if ( query.getSelectClause() != null ) { for ( Object element : query.getSelectClause().getFromElementsForLoad() ) { FromElement fromElement = (FromElement) element; EntityPersister entityPersister = fromElement.getEntityPersister(); <START> if ( entityPersister != null && entityPersister instanceof AbstractEntityPersister ) { <END> AbstractEntityPersister aep = (AbstractEntityPersister) entityPersister; String[] tables = aep.getTableNames(); result.addAll(Arrays.asList(tables)); } } } return result; }</code><technical_language>purpose. I wanted avoid creation of intermediate array list</technical_language>

Target:
private Set<String> findQueryReferencedTables(QueryNode query) { if ( !walker.getSessionFactoryHelper() .getFactory() .getSessionFactoryOptions() .isOmitJoinOfSuperclassTablesEnabled() ) { if ( LOG.isDebugEnabled() ) { LOG.debug( String.format( "Finding of query referenced tables is skipped because the feature is disabled. See %s", AvailableSettings.OMIT_JOIN_OF_SUPERCLASS_TABLES ) ); } return null; } if ( CollectionHelper.isNotEmpty( walker.getEnabledFilters() ) ) { LOG.debug( "Finding of query referenced tables is skipped because filters are enabled." ); return null; } if ( LOG.isDebugEnabled() ) { LOG.debug( TokenPrinters.REFERENCED_TABLES_PRINTER.showAsString( query, "Tables referenced from query nodes:" ) ); } Set<String> result = new HashSet<>(); collectReferencedTables( new ASTIterator( query ), result ); for (FromElement fromElement : (List<FromElement>) query.getFromClause().getFromElements()) { String role = fromElement.getRole(); if ( role != null ) { result.add( fromElement.getOrigin().getPropertyTableName(role.substring(role.lastIndexOf('.') + 1)) ); } AST withClauseAst = fromElement.getWithClauseAst(); if ( withClauseAst != null ) { collectReferencedTables( new ASTIterator( withClauseAst ), result ); } } if ( query.getSelectClause() != null ) { for ( Object element : query.getSelectClause().getFromElementsForLoad() ) { FromElement fromElement = (FromElement) element; EntityPersister entityPersister = fromElement.getEntityPersister(); if ( entityPersister != null && entityPersister instanceof AbstractEntityPersister ) { AbstractEntityPersister aep = (AbstractEntityPersister) entityPersister; String[] tables = aep.getTableNames(); Collections.addAll(result, tables); } } } return result; }