org.hibernate.loader
Class JoinWalker

java.lang.Object
  extended by org.hibernate.loader.JoinWalker
Direct Known Subclasses:
AbstractEntityJoinWalker, CollectionJoinWalker

public class JoinWalker
extends java.lang.Object

Walks the metamodel, searching for joins, and collecting together information needed by OuterJoinLoader.

Author:
Gavin King, Jon Lipsky
See Also:
OuterJoinLoader

Field Summary
protected  java.lang.String[] aliases
           
protected  java.util.List associations
           
protected  int[] collectionOwners
           
protected  CollectionPersister[] collectionPersisters
           
protected  java.lang.String[] collectionSuffixes
           
protected  LockMode[] lockModeArray
           
protected  EntityType[] ownerAssociationTypes
           
protected  int[] owners
           
protected  Loadable[] persisters
           
protected  java.lang.String sql
           
protected  java.lang.String[] suffixes
           
 
Constructor Summary
protected JoinWalker(SessionFactoryImplementor factory, java.util.Map enabledFilters)
           
 
Method Summary
protected static int countCollectionPersisters(java.util.List associations)
          Count the number of instances of Joinable which are actually also instances of PersistentCollection which are being fetched by outer join
protected static int countEntityPersisters(java.util.List associations)
          Count the number of instances of Joinable which are actually also instances of Loadable, or are one-to-many associations
protected  java.lang.String generateRootAlias(java.lang.String description)
           
protected  java.lang.String generateTableAlias(int n, java.lang.String path, Joinable joinable)
           
 java.lang.String[] getAliases()
           
 int[] getCollectionOwners()
           
 CollectionPersister[] getCollectionPersisters()
           
 java.lang.String[] getCollectionSuffixes()
           
protected  Dialect getDialect()
           
protected  java.util.Map getEnabledFilters()
           
protected  SessionFactoryImplementor getFactory()
           
protected  int getJoinType(AssociationType type, FetchMode config, java.lang.String path, java.lang.String lhsTable, java.lang.String[] lhsColumns, boolean nullable, int currentDepth, CascadeStyle cascadeStyle)
          Get the join type (inner, outer, etc) or -1 if the association should not be joined.
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
 LockMode[] getLockModeArray()
           
 EntityType[] getOwnerAssociationTypes()
           
 int[] getOwners()
           
 Loadable[] getPersisters()
           
 java.lang.String getSQLString()
           
 java.lang.String[] getSuffixes()
           
protected  void initPersisters(java.util.List associations, LockMode lockMode)
           
protected  boolean isDuplicateAssociation(java.lang.String foreignKeyTable, java.lang.String[] foreignKeyColumns)
          Used to detect circularities in the joined graph, note that this method is side-effecty
protected  boolean isDuplicateAssociation(java.lang.String lhsTable, java.lang.String[] lhsColumnNames, AssociationType type)
          Used to detect circularities in the joined graph, note that this method is side-effecty
protected  boolean isJoinable(int joinType, java.util.Set visitedAssociationKeys, java.lang.String lhsTable, java.lang.String[] lhsColumnNames, AssociationType type, int depth)
          Should we join this association?
protected  boolean isJoinedFetchEnabled(AssociationType type, FetchMode config, CascadeStyle cascadeStyle)
          Override on subclasses to enable or suppress joining of certain association types
protected  boolean isJoinedFetchEnabledInMapping(FetchMode config, AssociationType type)
          Does the mapping, and Hibernate default semantics, specify that this association should be fetched by outer joining
protected  boolean isTooDeep(int currentDepth)
           
protected  boolean isTooManyCollections()
           
protected static java.lang.String mergeOrderings(java.lang.String ordering1, java.lang.String ordering2)
           
protected  JoinFragment mergeOuterJoins(java.util.List associations)
          Generate a sequence of LEFT OUTER JOIN clauses for the given associations.
protected static java.lang.String orderBy(java.util.List associations)
          Get the order by string required for collection fetching
protected  java.lang.String orderBy(java.util.List associations, java.lang.String orderBy)
           
protected  java.lang.String selectString(java.util.List associations)
          Generate a select list of columns containing all properties of the entity classes
 void setAliases(java.lang.String[] aliases)
           
 void setCollectionOwners(int[] collectionOwners)
           
 void setCollectionPersisters(CollectionPersister[] collectionPersisters)
           
 void setCollectionSuffixes(java.lang.String[] collectionSuffixes)
           
 void setLockModeArray(LockMode[] lockModeArray)
           
 void setOwnerAssociationTypes(EntityType[] ownerAssociationType)
           
 void setOwners(int[] owners)
           
 void setPersisters(Loadable[] persisters)
           
 void setSql(java.lang.String sql)
           
 void setSuffixes(java.lang.String[] suffixes)
           
protected  void walkCollectionTree(QueryableCollection persister, java.lang.String alias)
          For a collection role, return a list of associations to be fetched by outerjoin
protected  void walkEntityTree(OuterJoinLoadable persister, java.lang.String alias)
          For an entity class, return a list of associations to be fetched by outerjoin
protected  java.lang.StringBuffer whereString(java.lang.String alias, java.lang.String[] columnNames, int batchSize)
          Render the where condition for a (batch) load by identifier / collection key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

associations

protected final java.util.List associations

suffixes

protected java.lang.String[] suffixes

collectionSuffixes

protected java.lang.String[] collectionSuffixes

persisters

protected Loadable[] persisters

owners

protected int[] owners

ownerAssociationTypes

protected EntityType[] ownerAssociationTypes

collectionPersisters

protected CollectionPersister[] collectionPersisters

collectionOwners

protected int[] collectionOwners

aliases

protected java.lang.String[] aliases

lockModeArray

protected LockMode[] lockModeArray

sql

protected java.lang.String sql
Constructor Detail

JoinWalker

protected JoinWalker(SessionFactoryImplementor factory,
                     java.util.Map enabledFilters)
Method Detail

getCollectionSuffixes

public java.lang.String[] getCollectionSuffixes()

setCollectionSuffixes

public void setCollectionSuffixes(java.lang.String[] collectionSuffixes)

getLockModeArray

public LockMode[] getLockModeArray()

setLockModeArray

public void setLockModeArray(LockMode[] lockModeArray)

getSuffixes

public java.lang.String[] getSuffixes()

setSuffixes

public void setSuffixes(java.lang.String[] suffixes)

getAliases

public java.lang.String[] getAliases()

setAliases

public void setAliases(java.lang.String[] aliases)

getCollectionOwners

public int[] getCollectionOwners()

setCollectionOwners

public void setCollectionOwners(int[] collectionOwners)

getCollectionPersisters

public CollectionPersister[] getCollectionPersisters()

setCollectionPersisters

public void setCollectionPersisters(CollectionPersister[] collectionPersisters)

getOwnerAssociationTypes

public EntityType[] getOwnerAssociationTypes()

setOwnerAssociationTypes

public void setOwnerAssociationTypes(EntityType[] ownerAssociationType)

getOwners

public int[] getOwners()

setOwners

public void setOwners(int[] owners)

getPersisters

public Loadable[] getPersisters()

setPersisters

public void setPersisters(Loadable[] persisters)

getSQLString

public java.lang.String getSQLString()

setSql

public void setSql(java.lang.String sql)

getFactory

protected SessionFactoryImplementor getFactory()

getDialect

protected Dialect getDialect()

getEnabledFilters

protected java.util.Map getEnabledFilters()

walkEntityTree

protected final void walkEntityTree(OuterJoinLoadable persister,
                                    java.lang.String alias)
                             throws MappingException
For an entity class, return a list of associations to be fetched by outerjoin

Throws:
MappingException

walkCollectionTree

protected final void walkCollectionTree(QueryableCollection persister,
                                        java.lang.String alias)
                                 throws MappingException
For a collection role, return a list of associations to be fetched by outerjoin

Throws:
MappingException

getJoinType

protected int getJoinType(AssociationType type,
                          FetchMode config,
                          java.lang.String path,
                          java.lang.String lhsTable,
                          java.lang.String[] lhsColumns,
                          boolean nullable,
                          int currentDepth,
                          CascadeStyle cascadeStyle)
                   throws MappingException
Get the join type (inner, outer, etc) or -1 if the association should not be joined. Override on subclasses.

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

protected java.lang.String generateTableAlias(int n,
                                              java.lang.String path,
                                              Joinable joinable)

generateRootAlias

protected java.lang.String generateRootAlias(java.lang.String description)

isDuplicateAssociation

protected boolean isDuplicateAssociation(java.lang.String foreignKeyTable,
                                         java.lang.String[] foreignKeyColumns)
Used to detect circularities in the joined graph, note that this method is side-effecty


isDuplicateAssociation

protected boolean isDuplicateAssociation(java.lang.String lhsTable,
                                         java.lang.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,
                             java.util.Set visitedAssociationKeys,
                             java.lang.String lhsTable,
                             java.lang.String[] lhsColumnNames,
                             AssociationType type,
                             int depth)
Should we join this association?


orderBy

protected java.lang.String orderBy(java.util.List associations,
                                   java.lang.String orderBy)

mergeOrderings

protected static java.lang.String mergeOrderings(java.lang.String ordering1,
                                                 java.lang.String ordering2)

mergeOuterJoins

protected final JoinFragment mergeOuterJoins(java.util.List associations)
                                      throws MappingException
Generate a sequence of LEFT OUTER JOIN clauses for the given associations.

Throws:
MappingException

countEntityPersisters

protected static final int countEntityPersisters(java.util.List associations)
                                          throws MappingException
Count the number of instances of Joinable which are actually also instances of Loadable, or are one-to-many associations

Throws:
MappingException

countCollectionPersisters

protected static final int countCollectionPersisters(java.util.List associations)
                                              throws MappingException
Count the number of instances of Joinable which are actually also instances of PersistentCollection which are being fetched by outer join

Throws:
MappingException

orderBy

protected static final java.lang.String orderBy(java.util.List associations)
                                         throws MappingException
Get the order by string required for collection fetching

Throws:
MappingException

whereString

protected java.lang.StringBuffer whereString(java.lang.String alias,
                                             java.lang.String[] columnNames,
                                             int batchSize)
Render the where condition for a (batch) load by identifier / collection key


initPersisters

protected void initPersisters(java.util.List associations,
                              LockMode lockMode)
                       throws MappingException
Throws:
MappingException

selectString

protected final java.lang.String selectString(java.util.List associations)
                                       throws MappingException
Generate a select list of columns containing all properties of the entity classes

Throws:
MappingException


Copyright © 2008 Hibernate.org. All Rights Reserved.