org.hibernate.hql.ast.util
Class SessionFactoryHelper

java.lang.Object
  extended by org.hibernate.hql.ast.util.SessionFactoryHelper

public class SessionFactoryHelper
extends Object

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

Author:
Joshua Davis

Constructor Summary
SessionFactoryHelper(SessionFactoryImplementor sfi)
          Construct a new SessionFactoryHelper instance.
 
Method Summary
 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, antlr.collections.AST first)
          Find the function return type given the function name and the first argument expression node.
static Queryable findQueryableUsingImports(SessionFactoryImplementor sfi, String className)
          Given a (potentially unqualified) class name, locate its persister.
 Queryable findQueryableUsingImports(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)
          Retreive the number of columns represented by this type.
 AssociationType getElementAssociationType(CollectionType collectionType)
          Essentially the same as getElementType(org.hibernate.type.CollectionType), 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 inheritence 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionFactoryHelper

public SessionFactoryHelper(SessionFactoryImplementor sfi)
Construct a new SessionFactoryHelper instance.

Parameters:
sfi - The SessionFactory impl to be encapsualted.
Method Detail

getFactory

public SessionFactoryImplementor getFactory()
Get a handle to the encapsulated SessionFactory.

Returns:
The encapsulated SessionFactory.

hasPhysicalDiscriminatorColumn

public boolean hasPhysicalDiscriminatorColumn(Queryable persister)
Does the given persister define a physical discriminator column for the purpose of inheritence discrimination?

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

getImportedClassName

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.

findQueryableUsingImports

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.

findQueryableUsingImports

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.

requireClassPersister

public EntityPersister requireClassPersister(String name)
                                      throws antlr.SemanticException
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:
antlr.SemanticException - Indicates the persister could not be found

getCollectionPersister

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.

requireQueryableCollection

public QueryableCollection requireQueryableCollection(String role)
                                               throws QueryException
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.

getCollectionElementColumns

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

createJoinSequence

public JoinSequence createJoinSequence()
Generate an empty join sequence instance.

Returns:
The generate join sequence.

createJoinSequence

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 qualifing 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.

createCollectionJoinSequence

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.

getIdentifierOrUniqueKeyPropertyName

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.

getColumnSpan

public int getColumnSpan(Type type)
Retreive the number of columns represented by this type.

Parameters:
type - The type.
Returns:
The number of columns.

getAssociatedEntityName

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.

getElementAssociationType

public AssociationType getElementAssociationType(CollectionType collectionType)
Essentially the same as getElementType(org.hibernate.type.CollectionType), 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.

findSQLFunction

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.

findFunctionReturnType

public Type findFunctionReturnType(String functionName,
                                   antlr.collections.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.

generateColumnNames

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

isStrictJPAQLComplianceEnabled

public boolean isStrictJPAQLComplianceEnabled()


Copyright © 2009 Hibernate.org. All Rights Reserved.