public class

SessionFactoryHelper

extends Object
java.lang.Object
   ↳ org.hibernate.hql.ast.util.SessionFactoryHelper

Class Overview

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

Summary

Public Constructors
SessionFactoryHelper(SessionFactoryImplementor sfi)
Construct a new SessionFactoryHelper instance.
Public Methods
JoinSequence createCollectionJoinSequence(QueryableCollection collPersister, String collectionName)
Create a join sequence rooted at the given collection.
JoinSequence createJoinSequence()
Generate an empty join sequence instance.
JoinSequence createJoinSequence(boolean implicit, AssociationType associationType, String tableAlias, int joinType, String[] columns)
Generate a join sequence representing the given association type.
Type findFunctionReturnType(String functionName, SQLFunction sqlFunction, AST firstArgument)
Type findFunctionReturnType(String functionName, AST first)
Find the function return type given the function name and the first argument expression node.
Queryable findQueryableUsingImports(String className)
Given a (potentially unqualified) class name, locate its persister.
static Queryable findQueryableUsingImports(SessionFactoryImplementor sfi, String className)
Given a (potentially unqualified) class name, locate its persister.
SQLFunction findSQLFunction(String functionName)
Locate a registered sql function by name.
String[][] generateColumnNames(Type[] sqlResultTypes)
String getAssociatedEntityName(CollectionType collectionType)
Given a collection type, determine the entity name of the elements contained within instance of that collection.
String[] getCollectionElementColumns(String role, String roleAlias)
Retrieves the column names corresponding to the collection elements for the given collection role.
QueryableCollection getCollectionPersister(String role)
Locate the collection persister by the collection role.
int getColumnSpan(Type type)
Retrieve the number of columns represented by this type.
AssociationType getElementAssociationType(CollectionType collectionType)
Essentially the same as #getElementType, but requiring that the element type be an association type.
SessionFactoryImplementor getFactory()
Get a handle to the encapsulated SessionFactory.
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.
String getImportedClassName(String className)
Given a (potentially unqualified) class name, locate its imported qualified name.
boolean hasPhysicalDiscriminatorColumn(Queryable persister)
Does the given persister define a physical discriminator column for the purpose of inheritance discrimination?
boolean isStrictJPAQLComplianceEnabled()
EntityPersister requireClassPersister(String name)
Locate the persister by class or entity name, requiring that such a persister exist.
QueryableCollection requireQueryableCollection(String role)
Locate the collection persister by the collection role, requiring that such a persister exist.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public SessionFactoryHelper (SessionFactoryImplementor sfi)

Construct a new SessionFactoryHelper instance.

Parameters
sfi The SessionFactory impl to be encapsulated.

Public Methods

public JoinSequence createCollectionJoinSequence (QueryableCollection collPersister, String collectionName)

Create a join sequence rooted at the given collection.

Parameters
collPersister The persister for the collection at which the join should be rooted.
collectionName The alias to use for qualifying column references.
Returns
  • The generated join sequence.

public JoinSequence createJoinSequence ()

Generate an empty join sequence instance.

Returns
  • The generate join sequence.

public JoinSequence createJoinSequence (boolean implicit, AssociationType associationType, String tableAlias, int joinType, String[] columns)

Generate a join sequence representing the given association type.

Parameters
implicit Should implicit joins (theta-style) or explicit joins (ANSI-style) be rendered
associationType The type representing the thing to be joined into.
tableAlias The table alias to use in qualifying the join conditions
joinType The type of join to render (inner, outer, etc); see JoinFragment
columns The columns making up the condition of the join.
Returns
  • The generated join sequence.

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

public Type findFunctionReturnType (String functionName, AST first)

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

Parameters
functionName The function name.
first The first argument expression.
Returns
  • the function return type given the function name and the first argument expression node.

public Queryable findQueryableUsingImports (String className)

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

Parameters
className The (potentially unqualified) class name.
Returns
  • The defined persister for this class, or null if none found.

public static Queryable findQueryableUsingImports (SessionFactoryImplementor sfi, String className)

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

Parameters
sfi The session factory implementor.
className The (potentially unqualified) class name.
Returns
  • The defined persister for this class, or null if none found.

public SQLFunction findSQLFunction (String functionName)

Locate a registered sql function by name.

Parameters
functionName The name of the function to locate
Returns
  • The sql function, or null if not found.

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

public String getAssociatedEntityName (CollectionType collectionType)

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

Parameters
collectionType The collection type to check.
Returns
  • The entity name of the elements of this collection.

public String[] getCollectionElementColumns (String role, String roleAlias)

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

Parameters
role The collection role
roleAlias The sql column-qualification alias (i.e., the table alias)
Returns
  • the collection element columns

public QueryableCollection getCollectionPersister (String role)

Locate the collection persister by the collection role.

Parameters
role The collection role name.
Returns
  • The defined CollectionPersister for this collection role, or null.

public int getColumnSpan (Type type)

Retrieve the number of columns represented by this type.

Parameters
type The type.
Returns
  • The number of columns.

public AssociationType getElementAssociationType (CollectionType collectionType)

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

Parameters
collectionType The collection type to be checked.
Returns
  • The AssociationType of the elements of the collection.

public SessionFactoryImplementor getFactory ()

Get a handle to the encapsulated SessionFactory.

Returns
  • The encapsulated SessionFactory.

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 The type representing the entity.
Returns
  • The corresponding property name
Throws
QueryException Indicates such a property could not be found.

public String getImportedClassName (String className)

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

Parameters
className The potentially unqualified class name
Returns
  • The qualified class name.

public boolean hasPhysicalDiscriminatorColumn (Queryable persister)

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

Parameters
persister The persister to be checked.
Returns
  • True if the persister does define an actual discriminator column.

public boolean isStrictJPAQLComplianceEnabled ()

public EntityPersister requireClassPersister (String name)

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

Parameters
name The class or entity name
Returns
  • The defined persister for this entity
Throws
Indicates the persister could not be found
SemanticException

public QueryableCollection requireQueryableCollection (String role)

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

Parameters
role The collection role name.
Returns
  • The defined CollectionPersister for this collection role.
Throws
QueryException Indicates that the collection persister could not be found.