Package org.hibernate.loader
Class JoinWalker
java.lang.Object
org.hibernate.loader.JoinWalker
- Direct Known Subclasses:
AbstractEntityJoinWalker,CollectionJoinWalker
Walks the metamodel, searching for joins, and collecting
together information needed by OuterJoinLoader.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]protected final Listprotected int[]protected CollectionPersister[]protected String[]protected LockMode[]protected LockOptionsprotected EntityType[]protected int[]protected Loadable[]protected Stringprotected String[] -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJoinWalker(SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) -
Method Summary
Modifier and TypeMethodDescriptionprotected static final intcountCollectionPersisters(List associations) Count the number of instances of Joinable which are actually also instances of PersistentCollection which are being fetched by outer joinprotected static final intcountEntityPersisters(List associations) Count the number of instances of Joinable which are actually also instances of Loadable, or are one-to-many associationsprotected StringgenerateRootAlias(String description) protected StringgenerateTableAlias(int n, PropertyPath path, Joinable joinable) String[]int[]String[]protected Dialectprotected SessionFactoryImplementorprotected intgetJoinType(boolean nullable, int currentDepth) Use an inner join if it is a non-null association and this is the "first" join in a seriesprotected intgetJoinType(OuterJoinLoadable persister, PropertyPath path, int propertyNumber, AssociationType associationType, FetchMode metadataFetchMode, CascadeStyle metadataCascadeStyle, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth) Determine the appropriate type of join (if any) to use to fetch the given association.protected intgetJoinType(AssociationType associationType, FetchMode config, PropertyPath path, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth, CascadeStyle cascadeStyle) Determine the appropriate associationType of join (if any) to use to fetch the given association.LockMode[]int[]Loadable[]String[]protected StringgetWithClause(PropertyPath path) protected booleanhasRestriction(PropertyPath path) protected voidinitPersisters(List associations, LockMode lockMode) protected voidinitPersisters(List associations, LockOptions lockOptions) protected voidinitPersisters(List associations, LockOptions lockOptions, JoinWalker.AssociationInitCallback callback) protected booleanisDuplicateAssociation(String foreignKeyTable, String[] foreignKeyColumns) Used to detect circularities in the joined graph, note that this method is side-effectyprotected booleanisDuplicateAssociation(String lhsTable, String[] lhsColumnNames, AssociationType type) Used to detect circularities in the joined graph, note that this method is side-effectyprotected booleanisJoinable(int joinType, Set visitedAssociationKeys, String lhsTable, String[] lhsColumnNames, AssociationType type, int depth) Should we join this association?protected booleanisJoinedFetchEnabled(AssociationType type, FetchMode config, CascadeStyle cascadeStyle) Override on subclasses to enable or suppress joining of certain association typesprotected booleanisJoinedFetchEnabledInMapping(FetchMode config, AssociationType type) Does the mapping, and Hibernate default semantics, specify that this association should be fetched by outer joiningprotected booleanisTooDeep(int currentDepth) protected booleanprotected static StringmergeOrderings(String ordering1, String ordering2) protected final JoinFragmentmergeOuterJoins(List associations) Generate a sequence of LEFT OUTER JOIN clauses for the given associations.protected static final StringGet the order by string required for collection fetchingprotected Stringprotected final StringselectString(List associations) Generate a select list of columns containing all properties of the entity classesvoidsetAliases(String[] aliases) voidsetCollectionOwners(int[] collectionOwners) voidsetCollectionPersisters(CollectionPersister[] collectionPersisters) voidsetCollectionSuffixes(String[] collectionSuffixes) voidsetOwnerAssociationTypes(EntityType[] ownerAssociationType) voidsetOwners(int[] owners) voidsetPersisters(Loadable[] persisters) voidvoidsetSuffixes(String[] suffixes) protected final voidwalkCollectionTree(QueryableCollection persister, String alias) For a collection role, return a list of associations to be fetched by outerjoinprotected final voidwalkEntityTree(OuterJoinLoadable persister, String alias) Walk the association tree for an entity, adding associations which should be join fetched to theassociationsinst var.protected StringBufferwhereString(String alias, String[] columnNames, int batchSize) Render the where condition for a (batch) load by identifier / collection key
-
Field Details
-
associations
-
suffixes
-
collectionSuffixes
-
persisters
-
owners
protected int[] owners -
ownerAssociationTypes
-
collectionPersisters
-
collectionOwners
protected int[] collectionOwners -
aliases
-
lockOptions
-
lockModeArray
-
sql
-
-
Constructor Details
-
JoinWalker
-
-
Method Details
-
getCollectionSuffixes
-
setCollectionSuffixes
-
getLockModeOptions
-
getLockModeArray
-
getSuffixes
-
setSuffixes
-
getAliases
-
setAliases
-
getCollectionOwners
public int[] getCollectionOwners() -
setCollectionOwners
public void setCollectionOwners(int[] collectionOwners) -
getCollectionPersisters
-
setCollectionPersisters
-
getOwnerAssociationTypes
-
setOwnerAssociationTypes
-
getOwners
public int[] getOwners() -
setOwners
public void setOwners(int[] owners) -
getPersisters
-
setPersisters
-
getSQLString
-
setSql
-
getFactory
-
getDialect
-
getLoadQueryInfluencers
-
hasRestriction
-
getWithClause
-
walkEntityTree
protected final void walkEntityTree(OuterJoinLoadable persister, String alias) throws MappingException Walk the association tree for an entity, adding associations which should be join fetched to theassociationsinst var. This form is the entry point into the walking for a given entity, starting the recursive calls intowalkEntityTree(org.hibernate.persister.entity.OuterJoinLoadable, String, PropertyPath,int).- Parameters:
persister- The persister representing the entity to be walked.alias- The (root) alias to use for this entity/persister.- Throws:
MappingException- ???
-
walkCollectionTree
protected final void walkCollectionTree(QueryableCollection persister, String alias) throws MappingException For a collection role, return a list of associations to be fetched by outerjoin- Throws:
MappingException
-
getJoinType
protected int getJoinType(OuterJoinLoadable persister, PropertyPath path, int propertyNumber, AssociationType associationType, FetchMode metadataFetchMode, CascadeStyle metadataCascadeStyle, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth) throws MappingException Determine the appropriate type of join (if any) to use to fetch the given association.- Parameters:
persister- The owner of the association.path- The path to the associationpropertyNumber- The property number representing the association.associationType- The association type.metadataFetchMode- The metadata-defined fetch mode.metadataCascadeStyle- The metadata-defined cascade style.lhsTable- The owner tablelhsColumns- The owner join columnsnullable- Is the association nullable.currentDepth- Current join depth- Returns:
- type of join to use (
JoinFragment.INNER_JOIN,JoinFragment.LEFT_OUTER_JOIN, or -1 to indicate no joining. - Throws:
MappingException- ??
-
getJoinType
protected int getJoinType(AssociationType associationType, FetchMode config, PropertyPath path, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth, CascadeStyle cascadeStyle) throws MappingException Determine the appropriate associationType of join (if any) to use to fetch the given association.- Parameters:
associationType- The association associationType.config- The metadata-defined fetch mode.path- The path to the associationlhsTable- The owner tablelhsColumns- The owner join columnsnullable- Is the association nullable.currentDepth- Current join depthcascadeStyle- The metadata-defined cascade style.- Returns:
- type of join to use (
JoinFragment.INNER_JOIN,JoinFragment.LEFT_OUTER_JOIN, or -1 to indicate no joining. - Throws:
MappingException- ??
-
getJoinType
protected int getJoinType(boolean nullable, int currentDepth) Use an inner join if it is a non-null association and this is the "first" join in a series -
isTooDeep
protected boolean isTooDeep(int currentDepth) -
isTooManyCollections
protected boolean isTooManyCollections() -
isJoinedFetchEnabledInMapping
protected boolean isJoinedFetchEnabledInMapping(FetchMode config, AssociationType type) throws MappingException Does the mapping, and Hibernate default semantics, specify that this association should be fetched by outer joining- Throws:
MappingException
-
isJoinedFetchEnabled
protected boolean isJoinedFetchEnabled(AssociationType type, FetchMode config, CascadeStyle cascadeStyle) Override on subclasses to enable or suppress joining of certain association types -
generateTableAlias
-
generateRootAlias
-
isDuplicateAssociation
Used to detect circularities in the joined graph, note that this method is side-effecty -
isDuplicateAssociation
protected boolean isDuplicateAssociation(String lhsTable, String[] lhsColumnNames, AssociationType type) Used to detect circularities in the joined graph, note that this method is side-effecty -
isJoinable
protected boolean isJoinable(int joinType, Set visitedAssociationKeys, String lhsTable, String[] lhsColumnNames, AssociationType type, int depth) Should we join this association? -
orderBy
-
mergeOrderings
-
mergeOuterJoins
Generate a sequence of LEFT OUTER JOIN clauses for the given associations.- Throws:
MappingException
-
countEntityPersisters
Count the number of instances of Joinable which are actually also instances of Loadable, or are one-to-many associations- Throws:
MappingException
-
countCollectionPersisters
Count the number of instances of Joinable which are actually also instances of PersistentCollection which are being fetched by outer join- Throws:
MappingException
-
orderBy
Get the order by string required for collection fetching- Throws:
MappingException
-
whereString
Render the where condition for a (batch) load by identifier / collection key -
initPersisters
- Throws:
MappingException
-
initPersisters
- Throws:
MappingException
-
initPersisters
protected void initPersisters(List associations, LockOptions lockOptions, JoinWalker.AssociationInitCallback callback) throws MappingException - Throws:
MappingException
-
selectString
Generate a select list of columns containing all properties of the entity classes- Throws:
MappingException
-