Top Description Fields Constructors Methods
org.hibernate.hql.internal.ast.util

public Class SessionFactoryHelper

extends Object
Class Inheritance
Imports
java.util.HashMap, .Map, org.hibernate.MappingException, .QueryException, org.hibernate.dialect.function.SQLFunction, org.hibernate.engine.internal.JoinSequence, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.hql.internal.NameGenerator, org.hibernate.hql.internal.ast.DetailedSemanticException, .QuerySyntaxException, org.hibernate.hql.internal.ast.tree.SqlNode, org.hibernate.persister.collection.CollectionPropertyMapping, .CollectionPropertyNames, .QueryableCollection, org.hibernate.persister.entity.EntityPersister, .PropertyMapping, .Queryable, org.hibernate.sql.JoinType, org.hibernate.type.AssociationType, .CollectionType, .EntityType, .ManyToOneType, .Type, antlr.SemanticException, antlr.collections.AST

Helper for performing common and/or complex operations with the SessionFactoryImplementor during translation of an HQL query.
Author
Joshua Davis

Field Summary

Modifier and TypeField and Description
private final Map<String, PropertyMapping>
private final SessionFactoryImplementor
sfi

Deprecated as a consequence of SessionFactoryImplementor being deprecated.

Constructor Summary

AccessConstructor and Description
public
SessionFactoryHelper(SessionFactoryImplementor
The SessionFactory impl to be encapsulated.
sfi
)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Construct a new SessionFactoryHelper instance.

Method Summary

Modifier and TypeMethod and Description
public JoinSequence

Returns:

The generated join sequence.
createCollectionJoinSequence
(QueryableCollection
The persister for the collection at which the join should be rooted.
collPersister
,
String
The alias to use for qualifying column references.
collectionName
)

Create a join sequence rooted at the given collection.

public JoinSequence

Returns:

The generate join sequence.
createJoinSequence
()

Generate an empty join sequence instance.

public JoinSequence

Returns:

The generated join sequence.
createJoinSequence
(boolean
Should implicit joins (theta-style) or explicit joins (ANSI-style) be rendered
implicit
,
AssociationType
The type representing the thing to be joined into.
associationType
,
String
The table alias to use in qualifying the join conditions
tableAlias
,
JoinType
The type of join to render (inner, outer, etc); see org.hibernate.sql.JoinFragment
joinType
,
String[]
The columns making up the condition of the join.
columns
)

Generate a join sequence representing the given association type.

public JoinSequence

Returns:

The generated join sequence.
createJoinSequence
(boolean
Should implicit joins (theta-style) or explicit joins (ANSI-style) be rendered
implicit
,
AssociationType
The type representing the thing to be joined into.
associationType
,
String
The table alias to use in qualifying the join conditions
tableAlias
,
JoinType
The type of join to render (inner, outer, etc); see org.hibernate.sql.JoinFragment
joinType
,
String[][]
The columns making up the condition of the join.
columns
)

Generate a join sequence representing the given association type.

public EntityPersister

Returns:

The defined persister for this entity, or null if none found.
findEntityPersisterByName
(String
The class or entity name
name
)

Locate the persister by class or entity name.

public Type

Returns:

the function return type given the function name and the first argument expression node.
findFunctionReturnType
(String
The function name.
functionName
,
AST
The first argument expression.
first
)

Find the function return type given the function name and the first argument expression node.

public Type
findFunctionReturnType(String functionName, SQLFunction sqlFunction, AST firstArgument)

public Queryable

Returns:

The defined persister for this class, or null if none found.
findQueryableUsingImports
(String
The (potentially unqualified) class name.
className
)

Given a (potentially unqualified) class name, locate its persister.

public static Queryable

Returns:

The defined persister for this class, or null if none found.
findQueryableUsingImports
(SessionFactoryImplementor
The session factory implementor.
sfi
,
String
The (potentially unqualified) class name.
className
)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Given a (potentially unqualified) class name, locate its persister.
public SQLFunction

Returns:

The sql function, or null if not found.
findSQLFunction
(String
The name of the function to locate
functionName
)

Locate a registered sql function by name.

public String[][]
generateColumnNames(Type[] sqlResultTypes)

public String

Returns:

The entity name of the elements of this collection.
getAssociatedEntityName
(CollectionType
The collection type to check.
collectionType
)

Given a collection type, determine the entity name of the elements contained within instance of that collection.

public String[]

Returns:

the collection element columns
getCollectionElementColumns
(String
The collection role
role
,
String
The sql column-qualification alias (i.e., the table alias)
roleAlias
)

Retrieves the column names corresponding to the collection elements for the given collection role.

public QueryableCollection

Returns:

The defined CollectionPersister for this collection role, or null.
getCollectionPersister
(String
The collection role name.
role
)

Locate the collection persister by the collection role.

public PropertyMapping

Returns:

The property mapping.
getCollectionPropertyMapping
(String
The collection role for which to retrieve the property mapping.
role
)

Retrieve a PropertyMapping describing the given collection role.

public int

Returns:

The number of columns.
getColumnSpan
(Type
The type.
type
)

Retrieve the number of columns represented by this type.

public AssociationType

Returns:

The AssociationType of the elements of the collection.
getElementAssociationType
(CollectionType
The collection type to be checked.
collectionType
)

Essentially the same as getElementType, but requiring that the element type be an association type.

private Type

Returns:

The Type of the elements of the collection.
getElementType
(CollectionType
The collection type to be checked.
collectionType
)

Given a collection type, determine the Type representing elements within instances of that collection.

public SessionFactoryImplementor

Returns:

The encapsulated SessionFactory.
getFactory
()

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Get a handle to the encapsulated SessionFactory.
public String

Returns:

The corresponding property name
getIdentifierOrUniqueKeyPropertyName
(EntityType
The type representing the entity.
entityType
)

Determine the name of the property for the entity encapsulated by the given type which represents the id or unique-key.

public String

Returns:

The qualified class name.
getImportedClassName
(String
The potentially unqualified class name
className
)

Given a (potentially unqualified) class name, locate its imported qualified name.

public boolean

Returns:

True if the persister does define an actual discriminator column.
hasPhysicalDiscriminatorColumn
(Queryable
The persister to be checked.
persister
)

Does the given persister define a physical discriminator column for the purpose of inheritance discrimination?

public boolean
public EntityPersister

Returns:

The defined persister for this entity
requireClassPersister
(String
The class or entity name
name
)

Locate the persister by class or entity name, requiring that such a persister exist.

public QueryableCollection

Returns:

The defined CollectionPersister for this collection role.
requireQueryableCollection
(String
The collection role name.
role
)

Locate the collection persister by the collection role, requiring that such a persister exist.

private SQLFunction

Returns:

The sql function.
requireSQLFunction
(String
The name of the function to locate
functionName
)

Locate a registered sql function by name, requiring that such a registered function exist.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

collectionPropertyMappingByRoleback to summary
private final Map<String, PropertyMapping> collectionPropertyMappingByRole
sfiback to summary
private final SessionFactoryImplementor sfi

Deprecated

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

Constructor Detail

SessionFactoryHelperback to summary
public SessionFactoryHelper(SessionFactoryImplementor sfi)

Deprecated

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

Construct a new SessionFactoryHelper instance.

Parameters
sfi:SessionFactoryImplementor

The SessionFactory impl to be encapsulated.

Method Detail

createCollectionJoinSequenceback to summary
public JoinSequence createCollectionJoinSequence(QueryableCollection collPersister, String collectionName)

Create a join sequence rooted at the given collection.

Parameters
collPersister:QueryableCollection

The persister for the collection at which the join should be rooted.

collectionName:String

The alias to use for qualifying column references.

Returns:JoinSequence

The generated join sequence.

createJoinSequenceback to summary
public JoinSequence createJoinSequence()

Generate an empty join sequence instance.

Returns:JoinSequence

The generate join sequence.

createJoinSequenceback to summary
public JoinSequence createJoinSequence(boolean implicit, AssociationType associationType, String tableAlias, JoinType joinType, String[] columns)

Generate a join sequence representing the given association type.

Parameters
implicit:boolean

Should implicit joins (theta-style) or explicit joins (ANSI-style) be rendered

associationType:AssociationType

The type representing the thing to be joined into.

tableAlias:String

The table alias to use in qualifying the join conditions

joinType:JoinType

The type of join to render (inner, outer, etc); see org.hibernate.sql.JoinFragment

columns:String[]

The columns making up the condition of the join.

Returns:JoinSequence

The generated join sequence.

createJoinSequenceback to summary
public JoinSequence createJoinSequence(boolean implicit, AssociationType associationType, String tableAlias, JoinType joinType, String[][] columns)

Generate a join sequence representing the given association type.

Parameters
implicit:boolean

Should implicit joins (theta-style) or explicit joins (ANSI-style) be rendered

associationType:AssociationType

The type representing the thing to be joined into.

tableAlias:String

The table alias to use in qualifying the join conditions

joinType:JoinType

The type of join to render (inner, outer, etc); see org.hibernate.sql.JoinFragment

columns:String[][]

The columns making up the condition of the join.

Returns:JoinSequence

The generated join sequence.

findEntityPersisterByNameback to summary
public EntityPersister findEntityPersisterByName(String name) throws MappingException

Locate the persister by class or entity name.

Parameters
name:String

The class or entity name

Returns:EntityPersister

The defined persister for this entity, or null if none found.

findFunctionReturnTypeback to summary
public Type findFunctionReturnType(String functionName, AST first)

Find the function return type given the function name and the first argument expression node.

Parameters
functionName:String

The function name.

first:AST

The first argument expression.

Returns:Type

the function return type given the function name and the first argument expression node.

findFunctionReturnTypeback to summary
public Type findFunctionReturnType(String functionName, SQLFunction sqlFunction, AST firstArgument)
findQueryableUsingImportsback to summary
public Queryable findQueryableUsingImports(String className)

Given a (potentially unqualified) class name, locate its persister.

Parameters
className:String

The (potentially unqualified) class name.

Returns:Queryable

The defined persister for this class, or null if none found.

findQueryableUsingImportsback to summary
public static Queryable findQueryableUsingImports(SessionFactoryImplementor sfi, String className)

Deprecated

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

Given a (potentially unqualified) class name, locate its persister.

Parameters
sfi:SessionFactoryImplementor

The session factory implementor.

className:String

The (potentially unqualified) class name.

Returns:Queryable

The defined persister for this class, or null if none found.

findSQLFunctionback to summary
public SQLFunction findSQLFunction(String functionName)

Locate a registered sql function by name.

Parameters
functionName:String

The name of the function to locate

Returns:SQLFunction

The sql function, or null if not found.

generateColumnNamesback to summary
public String[][] generateColumnNames(Type[] sqlResultTypes)
getAssociatedEntityNameback to summary
public String getAssociatedEntityName(CollectionType collectionType)

Given a collection type, determine the entity name of the elements contained within instance of that collection.

Parameters
collectionType:CollectionType

The collection type to check.

Returns:String

The entity name of the elements of this collection.

getCollectionElementColumnsback to summary
public String[] getCollectionElementColumns(String role, String roleAlias)

Retrieves the column names corresponding to the collection elements for the given collection role.

Parameters
role:String

The collection role

roleAlias:String

The sql column-qualification alias (i.e., the table alias)

Returns:String[]

the collection element columns

getCollectionPersisterback to summary
public QueryableCollection getCollectionPersister(String role)

Locate the collection persister by the collection role.

Parameters
role:String

The collection role name.

Returns:QueryableCollection

The defined CollectionPersister for this collection role, or null.

getCollectionPropertyMappingback to summary
public PropertyMapping getCollectionPropertyMapping(String role)

Retrieve a PropertyMapping describing the given collection role.

Parameters
role:String

The collection role for which to retrieve the property mapping.

Returns:PropertyMapping

The property mapping.

getColumnSpanback to summary
public int getColumnSpan(Type type)

Retrieve the number of columns represented by this type.

Parameters
type:Type

The type.

Returns:int

The number of columns.

getElementAssociationTypeback to summary
public AssociationType getElementAssociationType(CollectionType collectionType)

Essentially the same as getElementType, but requiring that the element type be an association type.

Parameters
collectionType:CollectionType

The collection type to be checked.

Returns:AssociationType

The AssociationType of the elements of the collection.

getElementTypeback to summary
private Type getElementType(CollectionType collectionType)

Given a collection type, determine the Type representing elements within instances of that collection.

Parameters
collectionType:CollectionType

The collection type to be checked.

Returns:Type

The Type of the elements of the collection.

getFactoryback to summary
public SessionFactoryImplementor getFactory()

Deprecated

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

Get a handle to the encapsulated SessionFactory.

Returns:SessionFactoryImplementor

The encapsulated SessionFactory.

getIdentifierOrUniqueKeyPropertyNameback to summary
public String getIdentifierOrUniqueKeyPropertyName(EntityType entityType)

Determine the name of the property for the entity encapsulated by the given type which represents the id or unique-key.

Parameters
entityType:EntityType

The type representing the entity.

Returns:String

The corresponding property name

Exceptions
QueryException:
Indicates such a property could not be found.
getImportedClassNameback to summary
public String getImportedClassName(String className)

Given a (potentially unqualified) class name, locate its imported qualified name.

Parameters
className:String

The potentially unqualified class name

Returns:String

The qualified class name.

hasPhysicalDiscriminatorColumnback to summary
public boolean hasPhysicalDiscriminatorColumn(Queryable persister)

Does the given persister define a physical discriminator column for the purpose of inheritance discrimination?

Parameters
persister:Queryable

The persister to be checked.

Returns:boolean

True if the persister does define an actual discriminator column.

isStrictJPAQLComplianceEnabledback to summary
public boolean isStrictJPAQLComplianceEnabled()
requireClassPersisterback to summary
public EntityPersister requireClassPersister(String name) throws SemanticException

Locate the persister by class or entity name, requiring that such a persister exist.

Parameters
name:String

The class or entity name

Returns:EntityPersister

The defined persister for this entity

Exceptions
SemanticException:
Indicates the persister could not be found
requireQueryableCollectionback to summary
public QueryableCollection requireQueryableCollection(String role) throws QueryException

Locate the collection persister by the collection role, requiring that such a persister exist.

Parameters
role:String

The collection role name.

Returns:QueryableCollection

The defined CollectionPersister for this collection role.

Exceptions
QueryException:
Indicates that the collection persister could not be found.
requireSQLFunctionback to summary
private SQLFunction requireSQLFunction(String functionName)

Locate a registered sql function by name, requiring that such a registered function exist.

Parameters
functionName:String

The name of the function to locate

Returns:SQLFunction

The sql function.

Exceptions
QueryException:
Indicates no matching sql functions could be found.