Source:
private Set<String> findQueryReferencedTables(QueryNode query) { Map<String, Object> sessionFactoryProperties = walker.getSessionFactoryHelper().getFactory().getProperties(); Object enabled = sessionFactoryProperties.getOrDefault( AvailableSettings.OMIT_JOIN_OF_SUPERCLASS_TABLES, DEFAULT_OMIT_JOIN_OF_SUPERCLASS_TABLES ); boolean disabled = !Boolean.parseBoolean( enabled.toString() ); if ( disabled ) { LOG.debug( "Finding of query referenced tables is skipped because the feature is disabled by " + "configuration. See " + AvailableSettings.OMIT_JOIN_OF_SUPERCLASS_TABLES ); return null; } if ( walker.getEnabledFilters() != null && !walker.getEnabledFilters().isEmpty() ) { 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<>(); List<FromReferenceNode> fromReferenceNodes = findAllNodes( query, FromReferenceNode.class ); for ( FromReferenceNode node : fromReferenceNodes ) { String[] tables = node.getReferencedTables(); if ( tables != null ) { Arrays.stream( tables ) .filter( Objects::nonNull ) .forEach( result::add ); } } 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(); Arrays.stream( tables ) .filter( Objects::nonNull ) .forEach( result::add ); } } } return result; }

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<>(); List<FromReferenceNode> fromReferenceNodes = findAllNodes( query, FromReferenceNode.class ); for ( FromReferenceNode node : fromReferenceNodes ) { String[] tables = node.getReferencedTables(); if ( tables != null ) { for ( String table : tables ) { result.add( table ); } } } 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(); for ( String table : tables ) { result.add( table ); } } } } return result; }