Top Description Inners Fields Constructors Methods
org.hibernate.engine.internal

public Class JoinSequence

extends Object
Class Inheritance
Known Direct Subclasses
org.hibernate.hql.internal.ast.tree.EntityJoinFromElement.EntityJoinJoinSequenceImpl
Imports
java.util.*, .Collections, org.hibernate.AssertionFailure, .MappingException, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.hql.internal.ast.tree.ImpliedFromElement, org.hibernate.internal.util.StringHelper, org.hibernate.persister.collection.AbstractCollectionPersister, .QueryableCollection, org.hibernate.persister.entity.AbstractEntityPersister, .Joinable, org.hibernate.sql.JoinFragment, .JoinType, .QueryJoinFragment, org.hibernate.type.AssociationType

A sequence of Join delegates to make it "easier" to work with joins. The "easier" part is obviously subjective ;)

Additionally JoinSequence is a directed graph of other JoinSequence instances, as represented by the next (setNext(JoinSequence)) pointer.

Authors
Gavin King, Steve Ebersole
See Also
JoinFragment

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
JoinSequence.Join

Represents a join

public static interface
JoinSequence.Selector

A subclass join selector

Field Summary

Modifier and TypeField and Description
private final boolean
private final StringBuilder
private final SessionFactoryImplementor
factory

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
private boolean
private final List<JoinSequence.Join>
private JoinSequence
private Set<String>
private String
private Joinable
private JoinSequence.Selector
private Set<String>
private boolean

Constructor Summary

AccessConstructor and Description
public
JoinSequence(SessionFactoryImplementor
The SessionFactory
factory
)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Constructs a JoinSequence

Method Summary

Modifier and TypeMethod and Description
public JoinSequence

Returns:

this, for method chaining
addCondition
(String
The condition
condition
)

Add a condition to this sequence.

public JoinSequence

Returns:

this, for method chaining
addCondition
(String
The alias to apply to the columns
alias
,
String[]
The columns to add checks for
columns
,
String
The conditions to check against the columns
condition
)

Add a condition to this sequence.

public JoinSequence

Returns:

The Join memento
addJoin
(AssociationType
The type of the association representing the join
associationType
,
String
The RHS alias for the join
alias
,
JoinType
The type of join (INNER, etc)
joinType
,
String[]
The LHS columns for the join condition
referencingKey
)

Add a join to this sequence

public JoinSequence

Returns:

The Join memento
addJoin
(AssociationType
The type of the association representing the join
associationType
,
String
The RHS alias for the join
alias
,
JoinType
The type of join (INNER, etc)
joinType
,
String[][]
The LHS columns for the join condition
referencingKeys
)

Add a join to this sequence

public JoinSequence

Returns:

The Join memento
addJoin
(ImpliedFromElement
The implied from element to embed
fromElement
)

Deprecated as a consequence of ImpliedFromElement being deprecated.
Embeds an implied from element into this sequence
private void
addSubclassJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin, boolean includeSubclassJoins, Set<String> treatAsDeclarations)

public void
applyTreatAsDeclarations(Set<String> treatAsDeclarations)

public JoinSequence

Returns:

The copy
copy
()

Create a full, although shallow, copy.

public JoinSequence
public JoinSequence.Join
public JoinSequence

Returns:

The JoinSequence that represents just the FROM clause parts
getFromPart
()

Retrieve a JoinSequence that represents just the FROM clause parts

protected Set<String>
private boolean
isAliasDereferenced(String withClauseFragment, String alias)

protected boolean
private boolean
private boolean
public boolean
private boolean
needsTableGroupJoin(List<JoinSequence.Join> joins, String withClauseFragment)

public JoinSequence

Returns:

this, for method chaining
setNext
(JoinSequence
The next JoinSequence in the directed graph
next
)

Sets the next join sequence

public void
setQueryReferencedTables(Set<String> queryReferencedTables)

Set all tables the query refers to.

public JoinSequence

Returns:

this, for method chaining
setRoot
(Joinable
The entity/collection that is the root of this JoinSequence
joinable
,
String
The alias associated with that joinable.
alias
)

Set the root of this JoinSequence.

public JoinSequence

Returns:

this, for method chaining
setSelector
(JoinSequence.Selector
The selector to apply
selector
)

Set the Selector to use to determine how subclass joins should be applied.

public JoinSequence

Returns:

this, for method chaining
setUseThetaStyle
(boolean
true indicates that theta-style joins should be used.
useThetaStyle
)

Should this JoinSequence use theta-style joining (both a FROM and WHERE component) in the rendered SQL?

public JoinFragment

Returns:

The JoinFragment
toJoinFragment
()

Generate a JoinFragment

public JoinFragment

Returns:

The JoinFragment
toJoinFragment
(Map<K, V>
The filters associated with the originating session to properly define join conditions
enabledFilters
,
boolean
Should all subclass joins be added to the rendered JoinFragment?
includeAllSubclassJoins
)

Generate a JoinFragment

public JoinFragment

Returns:

The JoinFragment
toJoinFragment
(Map<K, V>
The filters associated with the originating session to properly define join conditions
enabledFilters
,
boolean
Should all subclass joins be added to the rendered JoinFragment?
includeAllSubclassJoins
,
String
The with clause (which represents additional join restrictions) fragment
withClauseFragment
)

Generate a JoinFragment

public JoinFragment
toJoinFragment(Map<K, V> enabledFilters, boolean includeAllSubclassJoins, boolean renderSubclassJoins, String withClauseFragment)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

collectionJoinSubqueryback to summary
private final boolean collectionJoinSubquery
conditionsback to summary
private final StringBuilder conditions
factoryback to summary
private final SessionFactoryImplementor factory

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

isFromPartback to summary
private boolean isFromPart
joinsback to summary
private final List<JoinSequence.Join> joins
nextback to summary
private JoinSequence next
queryReferencedTablesback to summary
private Set<String> queryReferencedTables
rootAliasback to summary
private String rootAlias
rootJoinableback to summary
private Joinable rootJoinable
selectorback to summary
private JoinSequence.Selector selector
treatAsDeclarationsback to summary
private Set<String> treatAsDeclarations
useThetaStyleback to summary
private boolean useThetaStyle

Constructor Detail

JoinSequenceback to summary
public JoinSequence(SessionFactoryImplementor factory)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Constructs a JoinSequence

Parameters
factory:SessionFactoryImplementor

The SessionFactory

Method Detail

addConditionback to summary
public JoinSequence addCondition(String condition)

Add a condition to this sequence.

Parameters
condition:String

The condition

Returns:JoinSequence

this, for method chaining

addConditionback to summary
public JoinSequence addCondition(String alias, String[] columns, String condition)

Add a condition to this sequence. Typical usage here might be:

    addCondition( "a", {"c1", "c2"}, "?" )
to represent:
    "... a.c1 = ? and a.c2 = ? ..."
Parameters
alias:String

The alias to apply to the columns

columns:String[]

The columns to add checks for

condition:String

The conditions to check against the columns

Returns:JoinSequence

this, for method chaining

addJoinback to summary
public JoinSequence addJoin(AssociationType associationType, String alias, JoinType joinType, String[] referencingKey) throws MappingException

Add a join to this sequence

Parameters
associationType:AssociationType

The type of the association representing the join

alias:String

The RHS alias for the join

joinType:JoinType

The type of join (INNER, etc)

referencingKey:String[]

The LHS columns for the join condition

Returns:JoinSequence

The Join memento

Exceptions
MappingException:
Generally indicates a problem resolving the associationType to a Joinable
addJoinback to summary
public JoinSequence addJoin(AssociationType associationType, String alias, JoinType joinType, String[][] referencingKeys) throws MappingException

Add a join to this sequence

Parameters
associationType:AssociationType

The type of the association representing the join

alias:String

The RHS alias for the join

joinType:JoinType

The type of join (INNER, etc)

referencingKeys:String[][]

The LHS columns for the join condition

Returns:JoinSequence

The Join memento

Exceptions
MappingException:
Generally indicates a problem resolving the associationType to a Joinable
addJoinback to summary
public JoinSequence addJoin(ImpliedFromElement fromElement)

Deprecated

as a consequence of ImpliedFromElement being deprecated. See corresponding docs for further information.

Embeds an implied from element into this sequence

Parameters
fromElement:ImpliedFromElement

The implied from element to embed

Returns:JoinSequence

The Join memento

addSubclassJoinsback to summary
private void addSubclassJoins(JoinFragment joinFragment, String alias, Joinable joinable, boolean innerJoin, boolean includeSubclassJoins, Set<String> treatAsDeclarations)
applyTreatAsDeclarationsback to summary
public void applyTreatAsDeclarations(Set<String> treatAsDeclarations)
copyback to summary
public JoinSequence copy()

Create a full, although shallow, copy.

Returns:JoinSequence

The copy

copyForCollectionPropertyback to summary
public JoinSequence copyForCollectionProperty()
getFirstJoinback to summary
public JoinSequence.Join getFirstJoin()
getFromPartback to summary
public JoinSequence getFromPart()

Retrieve a JoinSequence that represents just the FROM clause parts

Returns:JoinSequence

The JoinSequence that represents just the FROM clause parts

getTreatAsDeclarationsback to summary
protected Set<String> getTreatAsDeclarations()
isAliasDereferencedback to summary
private boolean isAliasDereferenced(String withClauseFragment, String alias)
isIncludedback to summary
protected boolean isIncluded(String alias)
isManyToManyRootback to summary
private boolean isManyToManyRoot(Joinable joinable)
Annotations
@SuppressWarnings:SimplifiableIfStatement
isSubclassAliasDereferencedback to summary
private boolean isSubclassAliasDereferenced(JoinSequence.Join join, String withClauseFragment)
isThetaStyleback to summary
public boolean isThetaStyle()
needsTableGroupJoinback to summary
private boolean needsTableGroupJoin(List<JoinSequence.Join> joins, String withClauseFragment)
setNextback to summary
public JoinSequence setNext(JoinSequence next)

Sets the next join sequence

Parameters
next:JoinSequence

The next JoinSequence in the directed graph

Returns:JoinSequence

this, for method chaining

setQueryReferencedTablesback to summary
public void setQueryReferencedTables(Set<String> queryReferencedTables)

Set all tables the query refers to. It allows to optimize the query.

setRootback to summary
public JoinSequence setRoot(Joinable joinable, String alias)

Set the root of this JoinSequence. In SQL terms, this would be the driving table.

Parameters
joinable:Joinable

The entity/collection that is the root of this JoinSequence

alias:String

The alias associated with that joinable.

Returns:JoinSequence

this, for method chaining

setSelectorback to summary
public JoinSequence setSelector(JoinSequence.Selector selector)

Set the Selector to use to determine how subclass joins should be applied.

Parameters
selector:JoinSequence.Selector

The selector to apply

Returns:JoinSequence

this, for method chaining

setUseThetaStyleback to summary
public JoinSequence setUseThetaStyle(boolean useThetaStyle)

Should this JoinSequence use theta-style joining (both a FROM and WHERE component) in the rendered SQL?

Parameters
useThetaStyle:boolean

true indicates that theta-style joins should be used.

Returns:JoinSequence

this, for method chaining

toJoinFragmentback to summary
public JoinFragment toJoinFragment() throws MappingException

Generate a JoinFragment

Returns:JoinFragment

The JoinFragment

Exceptions
MappingException:
Indicates a problem access the provided metadata, or incorrect metadata
toJoinFragmentback to summary
public JoinFragment toJoinFragment(Map<K, V> enabledFilters, boolean includeAllSubclassJoins) throws MappingException

Generate a JoinFragment

Parameters
enabledFilters:Map<K, V>

The filters associated with the originating session to properly define join conditions

includeAllSubclassJoins:boolean

Should all subclass joins be added to the rendered JoinFragment?

Returns:JoinFragment

The JoinFragment

Exceptions
MappingException:
Indicates a problem access the provided metadata, or incorrect metadata
toJoinFragmentback to summary
public JoinFragment toJoinFragment(Map<K, V> enabledFilters, boolean includeAllSubclassJoins, String withClauseFragment) throws MappingException

Generate a JoinFragment

Parameters
enabledFilters:Map<K, V>

The filters associated with the originating session to properly define join conditions

includeAllSubclassJoins:boolean

Should all subclass joins be added to the rendered JoinFragment?

withClauseFragment:String

The with clause (which represents additional join restrictions) fragment

Returns:JoinFragment

The JoinFragment

Exceptions
MappingException:
Indicates a problem access the provided metadata, or incorrect metadata
toJoinFragmentback to summary
public JoinFragment toJoinFragment(Map<K, V> enabledFilters, boolean includeAllSubclassJoins, boolean renderSubclassJoins, String withClauseFragment) throws MappingException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.hibernate.engine.internal back to summary

public final Class JoinSequence.Join

extends Object
Class Inheritance

Represents a join

Field Summary

Modifier and TypeField and Description
private final String
private final AssociationType
private final Joinable
private final JoinType
private final String[][]

Constructor Summary

AccessConstructor and Description
pack-priv
Join(SessionFactoryImplementor factory, AssociationType associationType, String alias, JoinType joinType, String[][] lhsColumns)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.

Method Summary

Modifier and TypeMethod and Description
public String
public AssociationType
public Joinable
public JoinType
public String[][]
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

aliasback to summary
private final String alias
associationTypeback to summary
private final AssociationType associationType
joinableback to summary
private final Joinable joinable
joinTypeback to summary
private final JoinType joinType
lhsColumnsback to summary
private final String[][] lhsColumns

Constructor Detail

Joinback to summary
pack-priv Join(SessionFactoryImplementor factory, AssociationType associationType, String alias, JoinType joinType, String[][] lhsColumns) throws MappingException

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Method Detail

getAliasback to summary
public String getAlias()
getAssociationTypeback to summary
public AssociationType getAssociationType()
getJoinableback to summary
public Joinable getJoinable()
getJoinTypeback to summary
public JoinType getJoinType()
getLHSColumnsback to summary
public String[][] getLHSColumns()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.hibernate.engine.internal back to summary

public Interface JoinSequence.Selector


A subclass join selector

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the subclass joins should be included
includeSubclasses
(String
The alias
alias
)

Should subclasses be included in the rendered join sequence?

Method Detail

includeSubclassesback to summary
public boolean includeSubclasses(String alias)

Should subclasses be included in the rendered join sequence?

Parameters
alias:String

The alias

Returns:boolean

true if the subclass joins should be included