org.hibernate.persister.entity
Class AbstractEntityPersister

java.lang.Object
  extended byorg.hibernate.persister.entity.AbstractEntityPersister
All Implemented Interfaces:
ClassMetadata, EntityPersister, Joinable, LazyPropertyInitializer, Loadable, OuterJoinLoadable, PostInsertIdentityPersister, PropertyMapping, Queryable, SQLLoadable, UniqueKeyLoadable
Direct Known Subclasses:
JoinedSubclassEntityPersister, SingleTableEntityPersister, UnionSubclassEntityPersister

public abstract class AbstractEntityPersister
extends Object
implements OuterJoinLoadable, Queryable, ClassMetadata, UniqueKeyLoadable, SQLLoadable, LazyPropertyInitializer, PostInsertIdentityPersister

Basic functionality for persisting an entity via JDBC through either generated or custom SQL

Author:
Gavin King

Field Summary
protected  String[] customSQLDelete
           
protected  String[] customSQLInsert
           
protected  String[] customSQLUpdate
           
protected  boolean[] deleteCallable
           
static String ENTITY_CLASS
           
protected  boolean[] insertCallable
           
protected  BasicEntityPropertyMapping propertyMapping
           
protected  String rowIdName
           
protected  boolean[] updateCallable
           
 
Fields inherited from interface org.hibernate.persister.entity.Loadable
ROWID_ALIAS
 
Fields inherited from interface org.hibernate.persister.entity.EntityPersister
ENTITY_ID
 
Fields inherited from interface org.hibernate.intercept.LazyPropertyInitializer
UNFETCHED_PROPERTY
 
Constructor Summary
AbstractEntityPersister(PersistentClass persistentClass, CacheConcurrencyStrategy cache, SessionFactoryImplementor factory)
           
 
Method Summary
protected  void addDiscriminatorToInsert(Insert insert)
           
protected  void addDiscriminatorToSelect(SelectFragment select, String name, String suffix)
           
 void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session)
          Called just after the entities properties have been initialized
 void afterReassociate(Object entity, SessionImplementor session)
          Called just after the entity has been reassociated with the session
protected  boolean check(int rows, Serializable id, int tableNumber)
           
protected  String concretePropertySelectFragment(String alias, boolean[] includeProperty)
           
protected  String concretePropertySelectFragmentSansLeadingComma(String alias, boolean[] include)
           
 boolean consumesCollectionAlias()
          Very, very, very ugly...
 boolean consumesEntityAlias()
          Very, very, very ugly...
 int countSubclassProperties()
          How many properties are there, for this class and all subclasses?
protected  UniqueEntityLoader createEntityLoader(LockMode lockMode)
           
protected  UniqueEntityLoader createEntityLoader(LockMode lockMode, Map enabledFilters)
           
protected  String createFrom(int tableNumber, String alias)
           
protected  JoinFragment createJoin(int[] tableNumbers, String drivingAlias)
           
protected  JoinFragment createJoin(String name, boolean innerJoin, boolean includeSubclasses)
           
 Object createProxy(Serializable id, SessionImplementor session)
          Create a new proxy instance
protected  void createQueryLoader()
           
protected  SelectFragment createSelect(int[] subclassColumnNumbers, int[] subclassFormulaNumbers)
           
protected  void createUniqueKeyLoaders()
           
protected  String createWhereByKey(int tableNumber, String alias)
           
protected  int dehydrate(Serializable id, Object[] fields, boolean[] includeProperty, boolean[][] includeColumns, int j, PreparedStatement st, SessionImplementor session)
           
protected  int dehydrate(Serializable id, Object[] fields, Object rowId, boolean[] includeProperty, boolean[][] includeColumns, int j, PreparedStatement ps, SessionImplementor session, int index)
          Marshall the fields of a persistent instance to a prepared statement
protected  void delete(Serializable id, Object version, int j, Object object, String sql, SessionImplementor session)
          Perform an SQL DELETE
 void delete(Serializable id, Object version, Object object, SessionImplementor session)
          Delete an object
protected abstract  String filterFragment(String alias)
           
 String filterFragment(String alias, Map enabledFilters)
          Get the where clause filter, given a query alias and considering enabled session filters
 int[] findDirty(Object[] currentState, Object[] previousState, Object entity, SessionImplementor session)
          Locate the property-indices of all properties considered to be dirty.
 int[] findModified(Object[] old, Object[] current, Object entity, SessionImplementor session)
          Locate the property-indices of all properties considered to be dirty.
 String fromJoinFragment(String alias, boolean innerJoin, boolean includeSubclasses)
          Get the from clause part of any joins (optional operation)
protected  String generateDeleteString(int j)
          Generate the SQL that deletes a row by id (and version)
 String generateFilterConditionAlias(String rootAlias)
          The alias used for any filter conditions (mapped where-fragments or enabled-filters).
protected  String generateInsertGeneratedValuesSelectString()
           
protected  String generateInsertString(boolean[] includeProperty, int j)
           
protected  String generateInsertString(boolean identityInsert, boolean[] includeProperty)
           
protected  String generateInsertString(boolean identityInsert, boolean[] includeProperty, int j)
          Generate the SQL that inserts a row
protected  String generateLazySelectString()
           
protected  String generateLockString(LockMode lockMode)
          Generate the SQL that pessimistic locks a row by id (and version)
protected  String generateSelectVersionString()
          Generate the SQL that selects the version number by id
protected  String generateSnapshotSelectString()
           
protected  String generateTableAlias(String rootAlias, int tableNumber)
           
protected  String generateUpdateGeneratedValuesSelectString()
           
protected  String generateUpdateString(boolean[] includeProperty, int j, boolean useRowId)
           
protected  String generateUpdateString(boolean[] includeProperty, int j, Object[] oldFields, boolean useRowId)
          Generate the SQL that updates a row by id (and version)
 CacheConcurrencyStrategy getCache()
          Get the cache (optional operation)
 CacheEntryStructure getCacheEntryStructure()
          Get the cache structure
 CascadeStyle getCascadeStyle(int i)
          Get the cascade style of this (subclass closure) property
 ClassMetadata getClassMetadata()
          Get the user-visible metadata for the class (optional operation)
 Class getConcreteProxyClass(EntityMode entityMode)
          Get the proxy interface that instances of this concrete class will be cast to (optional operation).
 Object getCurrentVersion(Serializable id, SessionImplementor session)
          Retrieve the version number
 Object[] getDatabaseSnapshot(Serializable id, SessionImplementor session)
          Get the current database state of the object, in a "hydrated" form, without resolving identifiers
protected  String getDiscriminatorAlias()
           
 String getDiscriminatorAlias(String suffix)
          Get the result set aliases used for the identifier columns, given a suffix
 String getDiscriminatorColumnName()
           
protected  String getDiscriminatorFormulaTemplate()
           
protected  EntityMetamodel getEntityMetamodel()
           
 String getEntityName()
          The name of the entity
 EntityType getEntityType()
           
 SessionFactoryImplementor getFactory()
          Return the SessionFactory to which this persister "belongs".
 FetchMode getFetchMode(int i)
          May this (subclass closure) property be fetched using an SQL outerjoin?
 Serializable getIdentifier(Object object, EntityMode entityMode)
          Get the identifier of an instance (throw an exception if no identifier property)
protected  String[] getIdentifierAliases()
           
 String[] getIdentifierAliases(String suffix)
          Get the result set aliases used for the identifier columns, given a suffix
 String[] getIdentifierColumnNames()
          Get the names of columns used to persist the identifier
protected  int getIdentifierColumnSpan()
           
 IdentifierGenerator getIdentifierGenerator()
          Return the IdentifierGenerator for the class
 String getIdentifierPropertyName()
          Get the name of the identifier property (or return null)
 Type getIdentifierType()
          Get the identifier Hibernate type
 String getIdentitySelectString()
           
 String[] getKeyColumnNames()
          The columns to join on
protected abstract  String[] getKeyColumns(int j)
           
protected  Set getLazyProperties()
           
 Class getMappedClass(EntityMode entityMode)
          The persistent class, or null
 String getMappedSuperclass()
          Get the class that this class is mapped as a subclass of - not necessarily the direct superclass
 String getName()
          An identifying name; a class name or collection role name.
 int[] getNaturalIdentifierProperties()
          Which properties hold the natural id?
 Object[] getNaturalIdentifierSnapshot(Serializable id, SessionImplementor session)
          Retrieve the current state of the natural-id properties from the database.
 boolean[] getNonLazyPropertyUpdateability()
           
protected  boolean[] getPropertiesToInsert(Object[] fields)
          Transform the array of property indexes to an array of booleans, true when the property is insertable and non-null
protected  boolean[] getPropertiesToUpdate(int[] dirtyProperties, boolean hasDirtyCollection)
          Transform the array of property indexes to an array of booleans, true when the property is dirty
 String[] getPropertyAliases(String suffix, int i)
          Get the result set aliases used for the property columns, given a suffix (properties of this class, only).
 CascadeStyle[] getPropertyCascadeStyles()
          Get the cascade styles of the propertes (optional operation)
 boolean[] getPropertyCheckability()
          Get the "checkability" of the properties of this class (is the property dirty checked, does the cache need to be updated)
 String[] getPropertyColumnNames(int i)
          Get the result set column names mapped for this property (properties of this class, only).
 String[] getPropertyColumnNames(String propertyName)
          Get the column names for the given property path
protected  int getPropertyColumnSpan(int i)
           
 int getPropertyIndex(String propertyName)
          Get the property number of the unique key property
 boolean[] getPropertyInsertability()
          Get the "insertability" of the properties of this class (does the property appear in an SQL INSERT)
 boolean[] getPropertyInsertGeneration()
          Which of the properties of this class are database generated values on insert?
 boolean[] getPropertyLaziness()
          Get the "laziness" of the properties of this class
 String[] getPropertyNames()
          Get the names of the class' persistent properties
 boolean[] getPropertyNullability()
          Get the nullability of the class' persistent properties
protected  int getPropertySpan()
           
protected  String[] getPropertySubclassNames()
           
protected abstract  int[] getPropertyTableNumbers()
           
protected abstract  int[] getPropertyTableNumbersInSelect()
           
 Type getPropertyType(String propertyName)
          Get the type of a particular (named) property
 Type[] getPropertyTypes()
          Get the Hibernate types of the class properties
 boolean[] getPropertyUpdateability()
          Get the "updateability" of the properties of this class (does the property appear in an SQL UPDATE)
protected  boolean[] getPropertyUpdateability(Object entity, EntityMode entityMode)
          Which properties appear in the SQL update? (Initialized, updateable ones!)
 boolean[] getPropertyUpdateGeneration()
          Which of the properties of this class are database generated values on update?
 Object getPropertyValue(Object object, int i, EntityMode entityMode)
          Get the value of a particular property
 Object getPropertyValue(Object object, String propertyName, EntityMode entityMode)
          Get the value of a particular (named) property
 Object[] getPropertyValues(Object object, EntityMode entityMode)
          Extract the property values from the given entity.
 Object[] getPropertyValuesToInsert(Object object, Map mergeMap, SessionImplementor session)
          Return the values of the mapped properties of the object
 boolean[] getPropertyVersionability()
          Get the "versionability" of the properties of this class (is the property optimistic-locked)
 Serializable[] getQuerySpaces()
          Returns an array of objects that identify spaces in which properties of this class are persisted, for instances of this class and its subclasses.
 String getRootEntityName()
          Returns an object that identifies the space in which identifiers of this class hierarchy are unique.
 String[] getRootTableKeyColumnNames()
           
 String getSelectByUniqueKeyString(String propertyName)
           
protected  String getSequentialSelect(String entityName)
           
protected  String[] getSQLDeleteStrings()
           
protected  String getSQLIdentityInsertString()
          The query that inserts a row, letting the database generate an id
protected  String[] getSQLInsertStrings()
           
protected  String getSQLLazySelectString()
           
protected  String[] getSQLLazyUpdateByRowIdStrings()
           
protected  String[] getSQLLazyUpdateStrings()
           
protected  String getSQLSnapshotSelectString()
           
protected  String[] getSQLUpdateByRowIdStrings()
           
protected  String[] getSQLUpdateStrings()
           
protected  String getSQLWhereString(String alias)
           
protected  String[] getSubclassColumnAliasClosure()
           
protected  String[] getSubclassColumnClosure()
           
protected  boolean[] getSubclassColumnLazyiness()
           
protected abstract  int[] getSubclassColumnTableNumberClosure()
           
 EntityPersister getSubclassEntityPersister(Object instance, SessionFactoryImplementor factory, EntityMode entityMode)
          Get the persister for an instance of this class or a subclass
protected  String[] getSubclassFormulaAliasClosure()
           
protected  String[] getSubclassFormulaClosure()
           
protected  boolean[] getSubclassFormulaLazyiness()
           
protected abstract  int[] getSubclassFormulaTableNumberClosure()
           
protected  String[] getSubclassFormulaTemplateClosure()
           
 String[] getSubclassPropertyColumnAliases(String propertyName, String suffix)
          Return the column alias names used to persist/query the named property of the class or a subclass (optional operation).
protected  String[][] getSubclassPropertyColumnNameClosure()
           
 String[] getSubclassPropertyColumnNames(int i)
          Return the column names used to persist the numbered property of the class or a subclass.
 String[] getSubclassPropertyColumnNames(String propertyName)
          Return the column names used to persist/query the named property of the class or a subclass (optional operation).
protected  String[][] getSubclassPropertyFormulaTemplateClosure()
           
 String getSubclassPropertyName(int i)
          Get the name of the numbered property of the class or a subclass.
protected  String[] getSubclassPropertyNameClosure()
           
protected  String[] getSubclassPropertySubclassNameClosure()
           
protected abstract  int getSubclassPropertyTableNumber(int i)
           
 int getSubclassPropertyTableNumber(String propertyPath)
          Warning: When there are duplicated property names in the subclasses of the class, this method may return the wrong table number for the duplicated subclass property (note that SingleTableEntityPersister defines an overloaded form which takes the entity name.
 Type getSubclassPropertyType(int i)
          Get the type of the numbered property of the class or a subclass.
protected  Type[] getSubclassPropertyTypeClosure()
           
protected abstract  String[] getSubclassTableKeyColumns(int j)
           
abstract  String getSubclassTableName(int j)
          Get the name of the table with the given index from the internal array.
protected abstract  int getSubclassTableSpan()
           
protected abstract  String getTableName(int j)
           
protected abstract  int getTableSpan()
           
protected  boolean[] getTableUpdateNeeded(int[] dirtyProperties, boolean hasDirtyCollection)
          Decide which tables need to be updated
 String getTemporaryIdTableDDL()
          Get the appropriate DDL command for generating the temporary table to be used to (potentially) store id values when performing bulk update/deletes.
 String getTemporaryIdTableName()
          Get the name of the temporary table to be used to (potentially) store id values when performing bulk update/deletes.
protected  EntityTuplizer getTuplizer(EntityMode entityMode)
           
protected  EntityTuplizer getTuplizer(SessionImplementor session)
           
 Type getType()
          Get the type
 Object getVersion(Object object, EntityMode entityMode)
          Get the version number (or timestamp) from the object's version property (or return null if not versioned)
 String getVersionColumnName()
           
protected  String getVersionedTableName()
           
 int getVersionProperty()
          Get the index of the version property
protected  String getVersionSelectString()
           
 VersionType getVersionType()
          Get the type of versioning (optional operation)
 EntityMode guessEntityMode(Object object)
          Try to discover the entity mode from the entity instance
 boolean hasCache()
          Does this class have a cache.
 boolean hasCascades()
          Does this class declare any cascading save/update/deletes.
 boolean hasCollections()
          Do instances of this class contain collections.
protected  boolean hasEmbeddedCompositeIdentifier()
           
protected  boolean hasFormulaProperties()
           
 boolean hasIdentifierProperty()
          Does this class have an identifier property?
 boolean hasIdentifierPropertyOrEmbeddedCompositeIdentifier()
          Do detached instances of this class carry their own identifier value?
 boolean hasInsertGeneratedProperties()
          Does this entity define any properties as being database generated on insert?
 boolean hasLazyProperties()
          Does this entity define some lazy attributes?
 boolean hasMutableProperties()
          Does this entity declare any properties of mutable type?
 boolean hasNaturalIdentifier()
          Does this entity declare a natural id?
 boolean hasProxy()
          Does this class support dynamic proxies?
 boolean hasRowId()
          Does the result set contain rowids?
 boolean hasSequentialSelect()
           
 boolean hasSubclasses()
          Does this entity have mapped subclasses?
 boolean hasSubselectLoadableCollections()
          Does this entity own any collections which are fetchable by subselect?
 boolean hasUninitializedLazyProperties(Object object, EntityMode entityMode)
          Does the given instance have any uninitialized lazy properties?
 boolean hasUpdateGeneratedProperties()
          Does this entity define any properties as being database generated on update?
protected  boolean hasWhere()
           
 Object[] hydrate(ResultSet rs, Serializable id, Object object, Loadable rootLoadable, String[][] suffixedPropertyColumns, boolean allProperties, SessionImplementor session)
          Unmarshall the fields of a persistent instance from a result set, without resolving associations or collections.
 String identifierSelectFragment(String name, String suffix)
          Given a query alias and an identifying suffix, render the intentifier select fragment.
 boolean implementsLifecycle(EntityMode entityMode)
          Does the class implement the Lifecycle interface?
 boolean implementsValidatable(EntityMode entityMode)
          Does the class implement the Validatable interface?
 Object initializeLazyProperty(String fieldName, Object entity, SessionImplementor session)
          Initialize the property, and return its new value
protected  void initLockers()
           
protected  void initPropertyPaths(Mapping mapping)
           
protected  void initSubclassPropertyAliasesMap(PersistentClass model)
          Must be called by subclasses, at the end of their constructors
protected  Serializable insert(Object[] fields, boolean[] notNull, String sql, Object object, SessionImplementor session)
          Perform an SQL INSERT, and then retrieve a generated identifier
 Serializable insert(Object[] fields, Object object, SessionImplementor session)
          Persist an instance, using a natively generated identifier (optional operation)
protected  void insert(Serializable id, Object[] fields, boolean[] notNull, int j, String sql, Object object, SessionImplementor session)
          Perform an SQL INSERT
 void insert(Serializable id, Object[] fields, Object object, SessionImplementor session)
          Persist an instance
 Object instantiate(Serializable id, EntityMode entityMode)
          Create a class instance initialized with the given identifier
 boolean isAbstract()
          Is this an abstract class?
 boolean isBatchable()
           
 boolean isBatchLoadable()
          Is batch loading enabled?
 boolean isCacheInvalidationRequired()
          We can't immediately add to the cache if we have formulas which must be evaluated, or if we have the possibility of two concurrent updates to the same item being merged on the database.
protected abstract  boolean isClassOrSuperclassTable(int j)
           
 boolean isCollection()
          Is this instance actually a CollectionPersister?
 boolean isDefinedOnSubclass(int i)
          Is this property defined on a subclass of the mapped class.
protected  boolean isDeleteCallable(int j)
           
 boolean isExplicitPolymorphism()
          Is this class explicit polymorphism only?
 boolean isIdentifierAssignedByInsert()
          Is the identifier assigned before the insert by an IDGenerator.
 boolean isInherited()
          Does this entity extend a mapped superclass?
protected  boolean isInsertCallable(int j)
           
 boolean isInstance(Object object, EntityMode entityMode)
          Is the given object an instance of this entity?
 boolean isInstrumented(EntityMode entityMode)
          Has the class actually been bytecode instrumented?
protected  boolean isInverseSubclassTable(int j)
           
protected  boolean isInverseTable(int j)
           
 boolean isLazyPropertiesCacheable()
          Should lazy properties of this entity be cached?
 boolean isMultiTable()
          Is the inheritence hierarchy described by this persister contained across multiple tables?
 boolean isMutable()
          Are instances of this class mutable?
protected  boolean isNullableSubclassTable(int j)
           
protected  boolean isNullableTable(int j)
           
 boolean isPolymorphic()
           
protected abstract  boolean isPropertyOfTable(int property, int j)
           
 boolean isSelectBeforeUpdateRequired()
          Is select snapshot before update enabled?
 boolean isSubclassEntityName(String entityName)
          Is the given entity name the name of a subclass, or this class?
protected  boolean isSubclassPropertyDeferred(String propertyName, String entityName)
           
 boolean isSubclassPropertyNullable(int i)
          Is the numbered property of the class of subclass nullable?
protected  boolean isSubclassTableLazy(int j)
           
protected  boolean isSubclassTableSequentialSelect(int j)
           
protected abstract  boolean isTableCascadeDeleteEnabled(int j)
           
 Boolean isTransient(Object entity, SessionImplementor session)
          Is this a new transient instance?
protected  boolean isUpdateCallable(int j)
           
 boolean isVersioned()
          Are instances of this class versioned by a timestamp or version number column?
 boolean isVersionPropertyGenerated()
          Does this entity contain a version property that is defined to be database generated?
 boolean isVersionPropertyInsertable()
          Is the version property included in insert statements?
 Object load(Serializable id, Object optionalObject, LockMode lockMode, SessionImplementor session)
          Load an instance using either the forUpdateLoader or the outer joining loader, depending upon the value of the lock parameter
 Object loadByUniqueKey(String propertyName, Object uniqueKey, SessionImplementor session)
          Load an instance of the persistent class, by a unique key other than the primary key.
 void lock(Serializable id, Object version, Object object, LockMode lockMode, SessionImplementor session)
          Do a version check
protected  void logStaticSQL()
           
 String oneToManyFilterFragment(String alias)
           
protected  int optimisticLockMode()
           
protected  void postConstruct(Mapping mapping)
           
 void postInstantiate()
          Finish the initialization of this object, once all ClassPersisters have been instantiated.
 void processInsertGeneratedProperties(Serializable id, Object entity, Object[] state, SessionImplementor session)
          Perform a select to retrieve the values of any generated properties back from the database, injecting these generated values into the given entity as well as writing this state to the PersistenceContext.
 void processUpdateGeneratedProperties(Serializable id, Object entity, Object[] state, SessionImplementor session)
          Perform a select to retrieve the values of any generated properties back from the database, injecting these generated values into the given entity as well as writing this state to the PersistenceContext.
 String propertySelectFragment(String name, String suffix, boolean allProperties)
          Given a query alias and an identifying suffix, render the property select fragment.
protected  String renderSelect(int[] tableNumbers, int[] columnNumbers, int[] formulaNumbers)
           
 void resetIdentifier(Object entity, Serializable currentId, Object currentVersion, EntityMode entityMode)
          Set the identifier and version of the given instance back to its "unsaved" value, returning the id
 String selectFragment(Joinable rhs, String rhsAlias, String lhsAlias, String entitySuffix, String collectionSuffix, boolean includeCollectionColumns)
          All columns to select, when loading.
 String selectFragment(String alias, String suffix)
          Generate a list of collection index, key and element columns
 void setIdentifier(Object object, Serializable id, EntityMode entityMode)
          Set the identifier of an instance (or do nothing if no identifier property)
 void setPropertyValue(Object object, int i, Object value, EntityMode entityMode)
          Set the value of a particular property
 void setPropertyValue(Object object, String propertyName, Object value, EntityMode entityMode)
          Set the value of a particular (named) property
 void setPropertyValues(Object object, Object[] values, EntityMode entityMode)
          Set the given values to the mapped properties of the given object
 String[] toColumns(String propertyName)
          Given a property path, return the corresponding column name(s).
 String[] toColumns(String name, int i)
          Given the number of a property of a subclass, and a table alias, return the aliased column names.
 String[] toColumns(String alias, String propertyName)
          Given a query alias and a property path, return the qualified column name
 String toString()
           
 Type toType(String propertyName)
          Given a component path expression, get the type of the property
 void update(Serializable id, Object[] fields, int[] dirtyFields, boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object object, Object rowId, SessionImplementor session)
          Update an object
protected  boolean update(Serializable id, Object[] fields, Object[] oldFields, Object rowId, boolean[] includeProperty, int j, Object oldVersion, Object object, String sql, SessionImplementor session)
           
protected  void updateOrInsert(Serializable id, Object[] fields, Object[] oldFields, Object rowId, boolean[] includeProperty, int j, Object oldVersion, Object object, String sql, SessionImplementor session)
          Perform an SQL UPDATE or SQL INSERT
protected  boolean useDynamicInsert()
           
protected  boolean useDynamicUpdate()
           
protected  boolean useGetGeneratedKeys()
           
protected  boolean useInsertSelectIdentity()
           
 String whereJoinFragment(String alias, boolean innerJoin, boolean includeSubclasses)
          Get the where clause part of any joins (optional operation)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.hibernate.persister.entity.OuterJoinLoadable
fromTableFragment, getPropertyTableName, getSubclassPropertyTableName
 
Methods inherited from interface org.hibernate.persister.entity.Loadable
getDiscriminatorType, getSubclassForDiscriminatorValue
 
Methods inherited from interface org.hibernate.persister.entity.EntityPersister
getPropertySpaces
 
Methods inherited from interface org.hibernate.persister.entity.Joinable
getTableName
 
Methods inherited from interface org.hibernate.persister.entity.Queryable
getConstraintOrderedTableNameClosure, getContraintOrderedTableKeyColumnClosure, getDiscriminatorSQLValue
 

Field Detail

ENTITY_CLASS

public static final String ENTITY_CLASS
See Also:
Constant Field Values

rowIdName

protected final String rowIdName

insertCallable

protected boolean[] insertCallable

updateCallable

protected boolean[] updateCallable

deleteCallable

protected boolean[] deleteCallable

customSQLInsert

protected String[] customSQLInsert

customSQLUpdate

protected String[] customSQLUpdate

customSQLDelete

protected String[] customSQLDelete

propertyMapping

protected final BasicEntityPropertyMapping propertyMapping
Constructor Detail

AbstractEntityPersister

public AbstractEntityPersister(PersistentClass persistentClass,
                               CacheConcurrencyStrategy cache,
                               SessionFactoryImplementor factory)
                        throws HibernateException
Method Detail

addDiscriminatorToInsert

protected void addDiscriminatorToInsert(Insert insert)

addDiscriminatorToSelect

protected void addDiscriminatorToSelect(SelectFragment select,
                                        String name,
                                        String suffix)

getSubclassColumnTableNumberClosure

protected abstract int[] getSubclassColumnTableNumberClosure()

getSubclassFormulaTableNumberClosure

protected abstract int[] getSubclassFormulaTableNumberClosure()

getSubclassTableName

public abstract String getSubclassTableName(int j)
Description copied from interface: Queryable
Get the name of the table with the given index from the internal array.

Specified by:
getSubclassTableName in interface Queryable
Parameters:
j - The index into the internal array.
Returns:

getSubclassTableKeyColumns

protected abstract String[] getSubclassTableKeyColumns(int j)

isClassOrSuperclassTable

protected abstract boolean isClassOrSuperclassTable(int j)

getSubclassTableSpan

protected abstract int getSubclassTableSpan()

getTableSpan

protected abstract int getTableSpan()

isTableCascadeDeleteEnabled

protected abstract boolean isTableCascadeDeleteEnabled(int j)

getTableName

protected abstract String getTableName(int j)

getKeyColumns

protected abstract String[] getKeyColumns(int j)

isPropertyOfTable

protected abstract boolean isPropertyOfTable(int property,
                                             int j)

getPropertyTableNumbersInSelect

protected abstract int[] getPropertyTableNumbersInSelect()

getPropertyTableNumbers

protected abstract int[] getPropertyTableNumbers()

getSubclassPropertyTableNumber

protected abstract int getSubclassPropertyTableNumber(int i)

filterFragment

protected abstract String filterFragment(String alias)
                                  throws MappingException
Throws:
MappingException

getDiscriminatorColumnName

public String getDiscriminatorColumnName()
Specified by:
getDiscriminatorColumnName in interface Loadable
Returns:
the column name for the discriminator as specified in the mapping.

getDiscriminatorAlias

protected String getDiscriminatorAlias()

getDiscriminatorFormulaTemplate

protected String getDiscriminatorFormulaTemplate()

isInverseTable

protected boolean isInverseTable(int j)

isNullableTable

protected boolean isNullableTable(int j)

isNullableSubclassTable

protected boolean isNullableSubclassTable(int j)

isInverseSubclassTable

protected boolean isInverseSubclassTable(int j)

isSubclassEntityName

public boolean isSubclassEntityName(String entityName)
Description copied from interface: EntityPersister
Is the given entity name the name of a subclass, or this class?

Specified by:
isSubclassEntityName in interface EntityPersister

getRootTableKeyColumnNames

public String[] getRootTableKeyColumnNames()
Specified by:
getRootTableKeyColumnNames in interface PostInsertIdentityPersister

getSQLUpdateByRowIdStrings

protected String[] getSQLUpdateByRowIdStrings()

getSQLLazyUpdateByRowIdStrings

protected String[] getSQLLazyUpdateByRowIdStrings()

getSQLSnapshotSelectString

protected String getSQLSnapshotSelectString()

getSQLLazySelectString

protected String getSQLLazySelectString()

getSQLDeleteStrings

protected String[] getSQLDeleteStrings()

getSQLInsertStrings

protected String[] getSQLInsertStrings()

getSQLUpdateStrings

protected String[] getSQLUpdateStrings()

getSQLLazyUpdateStrings

protected String[] getSQLLazyUpdateStrings()

getSQLIdentityInsertString

protected String getSQLIdentityInsertString()
The query that inserts a row, letting the database generate an id


getVersionSelectString

protected String getVersionSelectString()

isInsertCallable

protected boolean isInsertCallable(int j)

isUpdateCallable

protected boolean isUpdateCallable(int j)

isDeleteCallable

protected boolean isDeleteCallable(int j)

isSubclassPropertyDeferred

protected boolean isSubclassPropertyDeferred(String propertyName,
                                             String entityName)

isSubclassTableSequentialSelect

protected boolean isSubclassTableSequentialSelect(int j)

hasSequentialSelect

public boolean hasSequentialSelect()

getTableUpdateNeeded

protected boolean[] getTableUpdateNeeded(int[] dirtyProperties,
                                         boolean hasDirtyCollection)
Decide which tables need to be updated


hasRowId

public boolean hasRowId()
Description copied from interface: Loadable
Does the result set contain rowids?

Specified by:
hasRowId in interface Loadable

generateLazySelectString

protected String generateLazySelectString()

initializeLazyProperty

public Object initializeLazyProperty(String fieldName,
                                     Object entity,
                                     SessionImplementor session)
                              throws HibernateException
Description copied from interface: LazyPropertyInitializer
Initialize the property, and return its new value

Specified by:
initializeLazyProperty in interface LazyPropertyInitializer
Throws:
HibernateException

isBatchable

public boolean isBatchable()

getQuerySpaces

public Serializable[] getQuerySpaces()
Description copied from interface: EntityPersister
Returns an array of objects that identify spaces in which properties of this class are persisted, for instances of this class and its subclasses.

Specified by:
getQuerySpaces in interface EntityPersister

getLazyProperties

protected Set getLazyProperties()

isBatchLoadable

public boolean isBatchLoadable()
Description copied from interface: EntityPersister
Is batch loading enabled?

Specified by:
isBatchLoadable in interface EntityPersister

getIdentifierColumnNames

public String[] getIdentifierColumnNames()
Description copied from interface: Queryable
Get the names of columns used to persist the identifier

Specified by:
getIdentifierColumnNames in interface Loadable

getIdentifierColumnSpan

protected int getIdentifierColumnSpan()

getIdentifierAliases

protected String[] getIdentifierAliases()

getVersionColumnName

public String getVersionColumnName()

getVersionedTableName

protected String getVersionedTableName()

getSubclassColumnLazyiness

protected boolean[] getSubclassColumnLazyiness()

getSubclassFormulaLazyiness

protected boolean[] getSubclassFormulaLazyiness()

isCacheInvalidationRequired

public boolean isCacheInvalidationRequired()
We can't immediately add to the cache if we have formulas which must be evaluated, or if we have the possibility of two concurrent updates to the same item being merged on the database. This can happen if (a) the item is not versioned and either (b) we have dynamic update enabled or (c) we have multiple tables holding the state of the item.

Specified by:
isCacheInvalidationRequired in interface EntityPersister

isLazyPropertiesCacheable

public boolean isLazyPropertiesCacheable()
Description copied from interface: EntityPersister
Should lazy properties of this entity be cached?

Specified by:
isLazyPropertiesCacheable in interface EntityPersister

selectFragment

public String selectFragment(String alias,
                             String suffix)
Description copied from interface: OuterJoinLoadable
Generate a list of collection index, key and element columns

Specified by:
selectFragment in interface OuterJoinLoadable

getIdentifierAliases

public String[] getIdentifierAliases(String suffix)
Description copied from interface: Loadable
Get the result set aliases used for the identifier columns, given a suffix

Specified by:
getIdentifierAliases in interface Loadable

getPropertyAliases

public String[] getPropertyAliases(String suffix,
                                   int i)
Description copied from interface: Loadable
Get the result set aliases used for the property columns, given a suffix (properties of this class, only).

Specified by:
getPropertyAliases in interface Loadable

getDiscriminatorAlias

public String getDiscriminatorAlias(String suffix)
Description copied from interface: Loadable
Get the result set aliases used for the identifier columns, given a suffix

Specified by:
getDiscriminatorAlias in interface Loadable

identifierSelectFragment

public String identifierSelectFragment(String name,
                                       String suffix)
Description copied from interface: Queryable
Given a query alias and an identifying suffix, render the intentifier select fragment.

Specified by:
identifierSelectFragment in interface Queryable

propertySelectFragment

public String propertySelectFragment(String name,
                                     String suffix,
                                     boolean allProperties)
Description copied from interface: Queryable
Given a query alias and an identifying suffix, render the property select fragment.

Specified by:
propertySelectFragment in interface Queryable

getDatabaseSnapshot

public Object[] getDatabaseSnapshot(Serializable id,
                                    SessionImplementor session)
                             throws HibernateException
Description copied from interface: EntityPersister
Get the current database state of the object, in a "hydrated" form, without resolving identifiers

Specified by:
getDatabaseSnapshot in interface EntityPersister
Returns:
null if there is no row in the database
Throws:
HibernateException

generateSelectVersionString

protected String generateSelectVersionString()
Generate the SQL that selects the version number by id


generateInsertGeneratedValuesSelectString

protected String generateInsertGeneratedValuesSelectString()

generateUpdateGeneratedValuesSelectString

protected String generateUpdateGeneratedValuesSelectString()

concretePropertySelectFragment

protected String concretePropertySelectFragment(String alias,
                                                boolean[] includeProperty)

generateSnapshotSelectString

protected String generateSnapshotSelectString()

lock

public void lock(Serializable id,
                 Object version,
                 Object object,
                 LockMode lockMode,
                 SessionImplementor session)
          throws HibernateException
Do a version check

Specified by:
lock in interface EntityPersister
Throws:
HibernateException

getCurrentVersion

public Object getCurrentVersion(Serializable id,
                                SessionImplementor session)
                         throws HibernateException
Retrieve the version number

Specified by:
getCurrentVersion in interface EntityPersister
Throws:
HibernateException

generateLockString

protected String generateLockString(LockMode lockMode)
Generate the SQL that pessimistic locks a row by id (and version)


initLockers

protected void initLockers()

toColumns

public String[] toColumns(String alias,
                          String propertyName)
                   throws QueryException
Description copied from interface: PropertyMapping
Given a query alias and a property path, return the qualified column name

Specified by:
toColumns in interface PropertyMapping
Throws:
QueryException

toColumns

public String[] toColumns(String propertyName)
                   throws QueryException
Description copied from interface: PropertyMapping
Given a property path, return the corresponding column name(s).

Specified by:
toColumns in interface PropertyMapping
Throws:
QueryException

toType

public Type toType(String propertyName)
            throws QueryException
Description copied from interface: PropertyMapping
Given a component path expression, get the type of the property

Specified by:
toType in interface PropertyMapping
Throws:
QueryException

getPropertyColumnNames

public String[] getPropertyColumnNames(String propertyName)
Description copied from interface: OuterJoinLoadable
Get the column names for the given property path

Specified by:
getPropertyColumnNames in interface OuterJoinLoadable

getSubclassPropertyTableNumber

public int getSubclassPropertyTableNumber(String propertyPath)
Warning: When there are duplicated property names in the subclasses of the class, this method may return the wrong table number for the duplicated subclass property (note that SingleTableEntityPersister defines an overloaded form which takes the entity name.

Specified by:
getSubclassPropertyTableNumber in interface Queryable
Parameters:
propertyPath - The name of the property.
Returns:
The nunber of the table to which the property is mapped.

generateTableAlias

protected String generateTableAlias(String rootAlias,
                                    int tableNumber)

toColumns

public String[] toColumns(String name,
                          int i)
Description copied from interface: OuterJoinLoadable
Given the number of a property of a subclass, and a table alias, return the aliased column names.

Specified by:
toColumns in interface OuterJoinLoadable

getPropertySubclassNames

protected String[] getPropertySubclassNames()

getPropertyColumnNames

public String[] getPropertyColumnNames(int i)
Description copied from interface: Loadable
Get the result set column names mapped for this property (properties of this class, only).

Specified by:
getPropertyColumnNames in interface Loadable

getPropertyColumnSpan

protected int getPropertyColumnSpan(int i)

hasFormulaProperties

protected boolean hasFormulaProperties()

getFetchMode

public FetchMode getFetchMode(int i)
Description copied from interface: OuterJoinLoadable
May this (subclass closure) property be fetched using an SQL outerjoin?

Specified by:
getFetchMode in interface OuterJoinLoadable

getCascadeStyle

public CascadeStyle getCascadeStyle(int i)
Description copied from interface: OuterJoinLoadable
Get the cascade style of this (subclass closure) property

Specified by:
getCascadeStyle in interface OuterJoinLoadable

getSubclassPropertyType

public Type getSubclassPropertyType(int i)
Description copied from interface: OuterJoinLoadable
Get the type of the numbered property of the class or a subclass.

Specified by:
getSubclassPropertyType in interface OuterJoinLoadable

getSubclassPropertyName

public String getSubclassPropertyName(int i)
Description copied from interface: OuterJoinLoadable
Get the name of the numbered property of the class or a subclass.

Specified by:
getSubclassPropertyName in interface OuterJoinLoadable

countSubclassProperties

public int countSubclassProperties()
Description copied from interface: OuterJoinLoadable
How many properties are there, for this class and all subclasses?

Specified by:
countSubclassProperties in interface OuterJoinLoadable

getSubclassPropertyColumnNames

public String[] getSubclassPropertyColumnNames(int i)
Description copied from interface: OuterJoinLoadable
Return the column names used to persist the numbered property of the class or a subclass.

Specified by:
getSubclassPropertyColumnNames in interface OuterJoinLoadable

isDefinedOnSubclass

public boolean isDefinedOnSubclass(int i)
Description copied from interface: OuterJoinLoadable
Is this property defined on a subclass of the mapped class.

Specified by:
isDefinedOnSubclass in interface OuterJoinLoadable

getSubclassPropertyFormulaTemplateClosure

protected String[][] getSubclassPropertyFormulaTemplateClosure()

getSubclassPropertyTypeClosure

protected Type[] getSubclassPropertyTypeClosure()

getSubclassPropertyColumnNameClosure

protected String[][] getSubclassPropertyColumnNameClosure()

getSubclassPropertyNameClosure

protected String[] getSubclassPropertyNameClosure()

getSubclassPropertySubclassNameClosure

protected String[] getSubclassPropertySubclassNameClosure()

getSubclassColumnClosure

protected String[] getSubclassColumnClosure()

getSubclassColumnAliasClosure

protected String[] getSubclassColumnAliasClosure()

getSubclassFormulaClosure

protected String[] getSubclassFormulaClosure()

getSubclassFormulaTemplateClosure

protected String[] getSubclassFormulaTemplateClosure()

getSubclassFormulaAliasClosure

protected String[] getSubclassFormulaAliasClosure()

getSubclassPropertyColumnAliases

public String[] getSubclassPropertyColumnAliases(String propertyName,
                                                 String suffix)
Description copied from interface: SQLLoadable
Return the column alias names used to persist/query the named property of the class or a subclass (optional operation).

Specified by:
getSubclassPropertyColumnAliases in interface SQLLoadable

getSubclassPropertyColumnNames

public String[] getSubclassPropertyColumnNames(String propertyName)
Description copied from interface: SQLLoadable
Return the column names used to persist/query the named property of the class or a subclass (optional operation).

Specified by:
getSubclassPropertyColumnNames in interface SQLLoadable

initSubclassPropertyAliasesMap

protected void initSubclassPropertyAliasesMap(PersistentClass model)
                                       throws MappingException
Must be called by subclasses, at the end of their constructors

Throws:
MappingException

loadByUniqueKey

public Object loadByUniqueKey(String propertyName,
                              Object uniqueKey,
                              SessionImplementor session)
                       throws HibernateException
Description copied from interface: UniqueKeyLoadable
Load an instance of the persistent class, by a unique key other than the primary key.

Specified by:
loadByUniqueKey in interface UniqueKeyLoadable
Throws:
HibernateException

getPropertyIndex

public int getPropertyIndex(String propertyName)
Description copied from interface: UniqueKeyLoadable
Get the property number of the unique key property

Specified by:
getPropertyIndex in interface UniqueKeyLoadable

createUniqueKeyLoaders

protected void createUniqueKeyLoaders()
                               throws MappingException
Throws:
MappingException

getSQLWhereString

protected String getSQLWhereString(String alias)

hasWhere

protected boolean hasWhere()

initPropertyPaths

protected void initPropertyPaths(Mapping mapping)
                          throws MappingException
Throws:
MappingException

createEntityLoader

protected UniqueEntityLoader createEntityLoader(LockMode lockMode,
                                                Map enabledFilters)
                                         throws MappingException
Throws:
MappingException

createEntityLoader

protected UniqueEntityLoader createEntityLoader(LockMode lockMode)
                                         throws MappingException
Throws:
MappingException

check

protected boolean check(int rows,
                        Serializable id,
                        int tableNumber)
                 throws HibernateException
Throws:
HibernateException

generateUpdateString

protected String generateUpdateString(boolean[] includeProperty,
                                      int j,
                                      boolean useRowId)

generateUpdateString

protected String generateUpdateString(boolean[] includeProperty,
                                      int j,
                                      Object[] oldFields,
                                      boolean useRowId)
Generate the SQL that updates a row by id (and version)


generateInsertString

protected String generateInsertString(boolean[] includeProperty,
                                      int j)

generateInsertString

protected String generateInsertString(boolean identityInsert,
                                      boolean[] includeProperty)

generateInsertString

protected String generateInsertString(boolean identityInsert,
                                      boolean[] includeProperty,
                                      int j)
Generate the SQL that inserts a row


generateDeleteString

protected String generateDeleteString(int j)
Generate the SQL that deletes a row by id (and version)


dehydrate

protected int dehydrate(Serializable id,
                        Object[] fields,
                        boolean[] includeProperty,
                        boolean[][] includeColumns,
                        int j,
                        PreparedStatement st,
                        SessionImplementor session)
                 throws HibernateException,
                        SQLException
Throws:
HibernateException
SQLException

dehydrate

protected int dehydrate(Serializable id,
                        Object[] fields,
                        Object rowId,
                        boolean[] includeProperty,
                        boolean[][] includeColumns,
                        int j,
                        PreparedStatement ps,
                        SessionImplementor session,
                        int index)
                 throws SQLException,
                        HibernateException
Marshall the fields of a persistent instance to a prepared statement

Throws:
SQLException
HibernateException

hydrate

public Object[] hydrate(ResultSet rs,
                        Serializable id,
                        Object object,
                        Loadable rootLoadable,
                        String[][] suffixedPropertyColumns,
                        boolean allProperties,
                        SessionImplementor session)
                 throws SQLException,
                        HibernateException
Unmarshall the fields of a persistent instance from a result set, without resolving associations or collections. Question: should this really be here, or should it be sent back to Loader?

Specified by:
hydrate in interface Loadable
Throws:
SQLException
HibernateException

useInsertSelectIdentity

protected boolean useInsertSelectIdentity()

useGetGeneratedKeys

protected boolean useGetGeneratedKeys()

getSequentialSelect

protected String getSequentialSelect(String entityName)

insert

protected Serializable insert(Object[] fields,
                              boolean[] notNull,
                              String sql,
                              Object object,
                              SessionImplementor session)
                       throws HibernateException
Perform an SQL INSERT, and then retrieve a generated identifier

Throws:
HibernateException

getIdentitySelectString

public String getIdentitySelectString()
Specified by:
getIdentitySelectString in interface PostInsertIdentityPersister

getSelectByUniqueKeyString

public String getSelectByUniqueKeyString(String propertyName)
Specified by:
getSelectByUniqueKeyString in interface PostInsertIdentityPersister

insert

protected void insert(Serializable id,
                      Object[] fields,
                      boolean[] notNull,
                      int j,
                      String sql,
                      Object object,
                      SessionImplementor session)
               throws HibernateException
Perform an SQL INSERT

Throws:
HibernateException

updateOrInsert

protected void updateOrInsert(Serializable id,
                              Object[] fields,
                              Object[] oldFields,
                              Object rowId,
                              boolean[] includeProperty,
                              int j,
                              Object oldVersion,
                              Object object,
                              String sql,
                              SessionImplementor session)
                       throws HibernateException
Perform an SQL UPDATE or SQL INSERT

Throws:
HibernateException

update

protected boolean update(Serializable id,
                         Object[] fields,
                         Object[] oldFields,
                         Object rowId,
                         boolean[] includeProperty,
                         int j,
                         Object oldVersion,
                         Object object,
                         String sql,
                         SessionImplementor session)
                  throws HibernateException
Throws:
HibernateException

delete

protected void delete(Serializable id,
                      Object version,
                      int j,
                      Object object,
                      String sql,
                      SessionImplementor session)
               throws HibernateException
Perform an SQL DELETE

Throws:
HibernateException

update

public void update(Serializable id,
                   Object[] fields,
                   int[] dirtyFields,
                   boolean hasDirtyCollection,
                   Object[] oldFields,
                   Object oldVersion,
                   Object object,
                   Object rowId,
                   SessionImplementor session)
            throws HibernateException
Update an object

Specified by:
update in interface EntityPersister
Throws:
HibernateException

insert

public Serializable insert(Object[] fields,
                           Object object,
                           SessionImplementor session)
                    throws HibernateException
Description copied from interface: EntityPersister
Persist an instance, using a natively generated identifier (optional operation)

Specified by:
insert in interface EntityPersister
Throws:
HibernateException

insert

public void insert(Serializable id,
                   Object[] fields,
                   Object object,
                   SessionImplementor session)
            throws HibernateException
Description copied from interface: EntityPersister
Persist an instance

Specified by:
insert in interface EntityPersister
Throws:
HibernateException

delete

public void delete(Serializable id,
                   Object version,
                   Object object,
                   SessionImplementor session)
            throws HibernateException
Delete an object

Specified by:
delete in interface EntityPersister
Throws:
HibernateException

logStaticSQL

protected void logStaticSQL()

filterFragment

public String filterFragment(String alias,
                             Map enabledFilters)
                      throws MappingException
Description copied from interface: Joinable
Get the where clause filter, given a query alias and considering enabled session filters

Specified by:
filterFragment in interface Joinable
Throws:
MappingException

generateFilterConditionAlias

public String generateFilterConditionAlias(String rootAlias)
Description copied from interface: Queryable
The alias used for any filter conditions (mapped where-fragments or enabled-filters).

This may or may not be different from the root alias depending upon the inheritence mapping strategy.

Specified by:
generateFilterConditionAlias in interface Queryable
Parameters:
rootAlias - The root alias
Returns:
The alias used for "filter conditions" within the where clause.

oneToManyFilterFragment

public String oneToManyFilterFragment(String alias)
                               throws MappingException
Specified by:
oneToManyFilterFragment in interface Joinable
Throws:
MappingException

fromJoinFragment

public String fromJoinFragment(String alias,
                               boolean innerJoin,
                               boolean includeSubclasses)
Description copied from interface: Joinable
Get the from clause part of any joins (optional operation)

Specified by:
fromJoinFragment in interface Joinable

whereJoinFragment

public String whereJoinFragment(String alias,
                                boolean innerJoin,
                                boolean includeSubclasses)
Description copied from interface: Joinable
Get the where clause part of any joins (optional operation)

Specified by:
whereJoinFragment in interface Joinable

isSubclassTableLazy

protected boolean isSubclassTableLazy(int j)

createJoin

protected JoinFragment createJoin(String name,
                                  boolean innerJoin,
                                  boolean includeSubclasses)

createJoin

protected JoinFragment createJoin(int[] tableNumbers,
                                  String drivingAlias)

createSelect

protected SelectFragment createSelect(int[] subclassColumnNumbers,
                                      int[] subclassFormulaNumbers)

createFrom

protected String createFrom(int tableNumber,
                            String alias)

createWhereByKey

protected String createWhereByKey(int tableNumber,
                                  String alias)

renderSelect

protected String renderSelect(int[] tableNumbers,
                              int[] columnNumbers,
                              int[] formulaNumbers)

postConstruct

protected void postConstruct(Mapping mapping)
                      throws MappingException
Throws:
MappingException

postInstantiate

public void postInstantiate()
                     throws MappingException
Description copied from interface: EntityPersister
Finish the initialization of this object, once all ClassPersisters have been instantiated. Called only once, before any other method.

Specified by:
postInstantiate in interface EntityPersister
Throws:
MappingException

createQueryLoader

protected void createQueryLoader()

load

public Object load(Serializable id,
                   Object optionalObject,
                   LockMode lockMode,
                   SessionImplementor session)
            throws HibernateException
Load an instance using either the forUpdateLoader or the outer joining loader, depending upon the value of the lock parameter

Specified by:
load in interface EntityPersister
Throws:
HibernateException

isSubclassPropertyNullable

public boolean isSubclassPropertyNullable(int i)
Description copied from interface: OuterJoinLoadable
Is the numbered property of the class of subclass nullable?

Specified by:
isSubclassPropertyNullable in interface OuterJoinLoadable

getPropertiesToUpdate

protected final boolean[] getPropertiesToUpdate(int[] dirtyProperties,
                                                boolean hasDirtyCollection)
Transform the array of property indexes to an array of booleans, true when the property is dirty


getPropertiesToInsert

protected boolean[] getPropertiesToInsert(Object[] fields)
Transform the array of property indexes to an array of booleans, true when the property is insertable and non-null


findDirty

public int[] findDirty(Object[] currentState,
                       Object[] previousState,
                       Object entity,
                       SessionImplementor session)
                throws HibernateException
Locate the property-indices of all properties considered to be dirty.

Specified by:
findDirty in interface EntityPersister
Parameters:
currentState - The current state of the entity (the state to be checked).
previousState - The previous state of the entity (the state to be checked against).
entity - The entity for which we are checking state dirtiness.
session - The session in which the check is ccurring.
Returns:
null or the indices of the dirty properties
Throws:
HibernateException

findModified

public int[] findModified(Object[] old,
                          Object[] current,
                          Object entity,
                          SessionImplementor session)
                   throws HibernateException
Locate the property-indices of all properties considered to be dirty.

Specified by:
findModified in interface EntityPersister
Parameters:
old - The old state of the entity.
current - The current state of the entity.
entity - The entity for which we are checking state modification.
session - The session in which the check is ccurring.
Returns:
null or the indices of the modified properties
Throws:
HibernateException

getPropertyUpdateability

protected boolean[] getPropertyUpdateability(Object entity,
                                             EntityMode entityMode)
Which properties appear in the SQL update? (Initialized, updateable ones!)


getTuplizer

protected EntityTuplizer getTuplizer(SessionImplementor session)

getTuplizer

protected EntityTuplizer getTuplizer(EntityMode entityMode)

getFactory

public SessionFactoryImplementor getFactory()
Description copied from interface: EntityPersister
Return the SessionFactory to which this persister "belongs".

Specified by:
getFactory in interface EntityPersister
Returns:
The owning SessionFactory.

getEntityMetamodel

protected EntityMetamodel getEntityMetamodel()

hasCache

public boolean hasCache()
Description copied from interface: EntityPersister
Does this class have a cache.

Specified by:
hasCache in interface EntityPersister

getCache

public CacheConcurrencyStrategy getCache()
Description copied from interface: EntityPersister
Get the cache (optional operation)

Specified by:
getCache in interface EntityPersister

getCacheEntryStructure

public CacheEntryStructure getCacheEntryStructure()
Description copied from interface: EntityPersister
Get the cache structure

Specified by:
getCacheEntryStructure in interface EntityPersister

getEntityName

public final String getEntityName()
Description copied from interface: ClassMetadata
The name of the entity

Specified by:
getEntityName in interface EntityPersister

getEntityType

public EntityType getEntityType()
Specified by:
getEntityType in interface OuterJoinLoadable

isPolymorphic

public boolean isPolymorphic()

isInherited

public boolean isInherited()
Description copied from interface: ClassMetadata
Does this entity extend a mapped superclass?

Specified by:
isInherited in interface EntityPersister

hasCascades

public boolean hasCascades()
Description copied from interface: EntityPersister
Does this class declare any cascading save/update/deletes.

Specified by:
hasCascades in interface EntityPersister

hasIdentifierProperty

public boolean hasIdentifierProperty()
Description copied from interface: ClassMetadata
Does this class have an identifier property?

Specified by:
hasIdentifierProperty in interface EntityPersister

getVersionType

public VersionType getVersionType()
Description copied from interface: EntityPersister
Get the type of versioning (optional operation)

Specified by:
getVersionType in interface EntityPersister

getVersionProperty

public int getVersionProperty()
Description copied from interface: ClassMetadata
Get the index of the version property

Specified by:
getVersionProperty in interface EntityPersister

isVersioned

public boolean isVersioned()
Description copied from interface: ClassMetadata
Are instances of this class versioned by a timestamp or version number column?

Specified by:
isVersioned in interface EntityPersister

isIdentifierAssignedByInsert

public boolean isIdentifierAssignedByInsert()
Description copied from interface: EntityPersister
Is the identifier assigned before the insert by an IDGenerator. Or is it returned by the insert() method? This determines which form of insert() will be called.

Specified by:
isIdentifierAssignedByInsert in interface EntityPersister

hasLazyProperties

public boolean hasLazyProperties()
Description copied from interface: EntityPersister
Does this entity define some lazy attributes?

Specified by:
hasLazyProperties in interface EntityPersister

afterReassociate

public void afterReassociate(Object entity,
                             SessionImplementor session)
Description copied from interface: EntityPersister
Called just after the entity has been reassociated with the session

Specified by:
afterReassociate in interface EntityPersister

isTransient

public Boolean isTransient(Object entity,
                           SessionImplementor session)
                    throws HibernateException
Description copied from interface: EntityPersister
Is this a new transient instance?

Specified by:
isTransient in interface EntityPersister
Throws:
HibernateException

hasCollections

public boolean hasCollections()
Description copied from interface: EntityPersister
Do instances of this class contain collections.

Specified by:
hasCollections in interface EntityPersister

hasMutableProperties

public boolean hasMutableProperties()
Description copied from interface: EntityPersister
Does this entity declare any properties of mutable type?

Specified by:
hasMutableProperties in interface EntityPersister

isMutable

public boolean isMutable()
Description copied from interface: ClassMetadata
Are instances of this class mutable?

Specified by:
isMutable in interface EntityPersister

isAbstract

public boolean isAbstract()
Description copied from interface: Queryable
Is this an abstract class?

Specified by:
isAbstract in interface Loadable

hasSubclasses

public boolean hasSubclasses()
Description copied from interface: ClassMetadata
Does this entity have mapped subclasses?

Specified by:
hasSubclasses in interface Loadable

hasProxy

public boolean hasProxy()
Description copied from interface: ClassMetadata
Does this class support dynamic proxies?

Specified by:
hasProxy in interface EntityPersister

getIdentifierGenerator

public IdentifierGenerator getIdentifierGenerator()
                                           throws HibernateException
Description copied from interface: EntityPersister
Return the IdentifierGenerator for the class

Specified by:
getIdentifierGenerator in interface EntityPersister
Throws:
HibernateException

getRootEntityName

public String getRootEntityName()
Description copied from interface: EntityPersister
Returns an object that identifies the space in which identifiers of this class hierarchy are unique. A table name, a JNDI URL, etc.

Specified by:
getRootEntityName in interface EntityPersister

getClassMetadata

public ClassMetadata getClassMetadata()
Description copied from interface: EntityPersister
Get the user-visible metadata for the class (optional operation)

Specified by:
getClassMetadata in interface EntityPersister

getMappedSuperclass

public String getMappedSuperclass()
Description copied from interface: Queryable
Get the class that this class is mapped as a subclass of - not necessarily the direct superclass

Specified by:
getMappedSuperclass in interface Queryable

isExplicitPolymorphism

public boolean isExplicitPolymorphism()
Description copied from interface: Queryable
Is this class explicit polymorphism only?

Specified by:
isExplicitPolymorphism in interface Queryable

useDynamicUpdate

protected boolean useDynamicUpdate()

useDynamicInsert

protected boolean useDynamicInsert()

hasEmbeddedCompositeIdentifier

protected boolean hasEmbeddedCompositeIdentifier()

hasIdentifierPropertyOrEmbeddedCompositeIdentifier

public boolean hasIdentifierPropertyOrEmbeddedCompositeIdentifier()
Description copied from interface: EntityPersister
Do detached instances of this class carry their own identifier value?

Specified by:
hasIdentifierPropertyOrEmbeddedCompositeIdentifier in interface EntityPersister

getKeyColumnNames

public String[] getKeyColumnNames()
Description copied from interface: Joinable
The columns to join on

Specified by:
getKeyColumnNames in interface Joinable

getName

public String getName()
Description copied from interface: Joinable
An identifying name; a class name or collection role name.

Specified by:
getName in interface Joinable

isCollection

public boolean isCollection()
Description copied from interface: Joinable
Is this instance actually a CollectionPersister?

Specified by:
isCollection in interface Joinable

consumesEntityAlias

public boolean consumesEntityAlias()
Description copied from interface: Joinable
Very, very, very ugly...

Specified by:
consumesEntityAlias in interface Joinable
Returns:
Does this persister "consume" entity column aliases in the result set?

consumesCollectionAlias

public boolean consumesCollectionAlias()
Description copied from interface: Joinable
Very, very, very ugly...

Specified by:
consumesCollectionAlias in interface Joinable
Returns:
Does this persister "consume" collection column aliases in the result set?

getPropertyType

public Type getPropertyType(String propertyName)
                     throws MappingException
Description copied from interface: ClassMetadata
Get the type of a particular (named) property

Specified by:
getPropertyType in interface EntityPersister
Throws:
MappingException

getType

public Type getType()
Description copied from interface: SQLLoadable
Get the type

Specified by:
getType in interface PropertyMapping

isSelectBeforeUpdateRequired

public boolean isSelectBeforeUpdateRequired()
Description copied from interface: EntityPersister
Is select snapshot before update enabled?

Specified by:
isSelectBeforeUpdateRequired in interface EntityPersister

optimisticLockMode

protected final int optimisticLockMode()

createProxy

public Object createProxy(Serializable id,
                          SessionImplementor session)
                   throws HibernateException
Description copied from interface: EntityPersister
Create a new proxy instance

Specified by:
createProxy in interface EntityPersister
Throws:
HibernateException

toString

public String toString()

selectFragment

public final String selectFragment(Joinable rhs,
                                   String rhsAlias,
                                   String lhsAlias,
                                   String entitySuffix,
                                   String collectionSuffix,
                                   boolean includeCollectionColumns)
Description copied from interface: Joinable
All columns to select, when loading.

Specified by:
selectFragment in interface Joinable

isInstrumented

public boolean isInstrumented(EntityMode entityMode)
Description copied from interface: EntityPersister
Has the class actually been bytecode instrumented?

Specified by:
isInstrumented in interface EntityPersister

hasInsertGeneratedProperties

public boolean hasInsertGeneratedProperties()
Description copied from interface: EntityPersister
Does this entity define any properties as being database generated on insert?

Specified by:
hasInsertGeneratedProperties in interface EntityPersister
Returns:
True if this entity contains at least one property defined as generated (including version property, but not identifier).

hasUpdateGeneratedProperties

public boolean hasUpdateGeneratedProperties()
Description copied from interface: EntityPersister
Does this entity define any properties as being database generated on update?

Specified by:
hasUpdateGeneratedProperties in interface EntityPersister
Returns:
True if this entity contains at least one property defined as generated (including version property, but not identifier).

isVersionPropertyGenerated

public boolean isVersionPropertyGenerated()
Description copied from interface: EntityPersister
Does this entity contain a version property that is defined to be database generated?

Specified by:
isVersionPropertyGenerated in interface EntityPersister
Returns:
true if this entity contains a version property and that property has been marked as generated.

isVersionPropertyInsertable

public boolean isVersionPropertyInsertable()
Description copied from interface: Queryable
Is the version property included in insert statements?

Specified by:
isVersionPropertyInsertable in interface Queryable

afterInitialize

public void afterInitialize(Object entity,
                            boolean lazyPropertiesAreUnfetched,
                            SessionImplementor session)
Description copied from interface: EntityPersister
Called just after the entities properties have been initialized

Specified by:
afterInitialize in interface EntityPersister

getPropertyNames

public String[] getPropertyNames()
Description copied from interface: ClassMetadata
Get the names of the class' persistent properties

Specified by:
getPropertyNames in interface EntityPersister

getPropertyTypes

public Type[] getPropertyTypes()
Description copied from interface: ClassMetadata
Get the Hibernate types of the class properties

Specified by:
getPropertyTypes in interface EntityPersister

getPropertyLaziness

public boolean[] getPropertyLaziness()
Description copied from interface: ClassMetadata
Get the "laziness" of the properties of this class

Specified by:
getPropertyLaziness in interface EntityPersister

getPropertyUpdateability

public boolean[] getPropertyUpdateability()
Description copied from interface: EntityPersister
Get the "updateability" of the properties of this class (does the property appear in an SQL UPDATE)

Specified by:
getPropertyUpdateability in interface EntityPersister

getPropertyCheckability

public boolean[] getPropertyCheckability()
Description copied from interface: EntityPersister
Get the "checkability" of the properties of this class (is the property dirty checked, does the cache need to be updated)

Specified by:
getPropertyCheckability in interface EntityPersister

getNonLazyPropertyUpdateability

public boolean[] getNonLazyPropertyUpdateability()

getPropertyInsertability

public boolean[] getPropertyInsertability()
Description copied from interface: EntityPersister
Get the "insertability" of the properties of this class (does the property appear in an SQL INSERT)

Specified by:
getPropertyInsertability in interface EntityPersister

getPropertyInsertGeneration

public boolean[] getPropertyInsertGeneration()
Description copied from interface: EntityPersister
Which of the properties of this class are database generated values on insert?

Specified by:
getPropertyInsertGeneration in interface EntityPersister

getPropertyUpdateGeneration

public boolean[] getPropertyUpdateGeneration()
Description copied from interface: EntityPersister
Which of the properties of this class are database generated values on update?

Specified by:
getPropertyUpdateGeneration in interface EntityPersister

getPropertyNullability

public boolean[] getPropertyNullability()
Description copied from interface: ClassMetadata
Get the nullability of the class' persistent properties

Specified by:
getPropertyNullability in interface EntityPersister

getPropertyVersionability

public boolean[] getPropertyVersionability()
Description copied from interface: EntityPersister
Get the "versionability" of the properties of this class (is the property optimistic-locked)

Specified by:
getPropertyVersionability in interface EntityPersister

getPropertyCascadeStyles

public CascadeStyle[] getPropertyCascadeStyles()
Description copied from interface: EntityPersister
Get the cascade styles of the propertes (optional operation)

Specified by:
getPropertyCascadeStyles in interface EntityPersister

getMappedClass

public final Class getMappedClass(EntityMode entityMode)
Description copied from interface: ClassMetadata
The persistent class, or null

Specified by:
getMappedClass in interface EntityPersister

implementsLifecycle

public boolean implementsLifecycle(EntityMode entityMode)
Description copied from interface: ClassMetadata
Does the class implement the Lifecycle interface?

Specified by:
implementsLifecycle in interface EntityPersister

implementsValidatable

public boolean implementsValidatable(EntityMode entityMode)
Description copied from interface: ClassMetadata
Does the class implement the Validatable interface?

Specified by:
implementsValidatable in interface EntityPersister

getConcreteProxyClass

public Class getConcreteProxyClass(EntityMode entityMode)
Description copied from interface: EntityPersister
Get the proxy interface that instances of this concrete class will be cast to (optional operation).

Specified by:
getConcreteProxyClass in interface EntityPersister

setPropertyValues

public void setPropertyValues(Object object,
                              Object[] values,
                              EntityMode entityMode)
                       throws HibernateException
Description copied from interface: ClassMetadata
Set the given values to the mapped properties of the given object

Specified by:
setPropertyValues in interface EntityPersister
Throws:
HibernateException

setPropertyValue

public void setPropertyValue(Object object,
                             int i,
                             Object value,
                             EntityMode entityMode)
                      throws HibernateException
Description copied from interface: EntityPersister
Set the value of a particular property

Specified by:
setPropertyValue in interface EntityPersister
Throws:
HibernateException

getPropertyValues

public Object[] getPropertyValues(Object object,
                                  EntityMode entityMode)
                           throws HibernateException
Description copied from interface: ClassMetadata
Extract the property values from the given entity.

Specified by:
getPropertyValues in interface EntityPersister
Throws:
HibernateException

getPropertyValue

public Object getPropertyValue(Object object,
                               int i,
                               EntityMode entityMode)
                        throws HibernateException
Description copied from interface: EntityPersister
Get the value of a particular property

Specified by:
getPropertyValue in interface EntityPersister
Throws:
HibernateException

getPropertyValue

public Object getPropertyValue(Object object,
                               String propertyName,
                               EntityMode entityMode)
                        throws HibernateException
Description copied from interface: ClassMetadata
Get the value of a particular (named) property

Specified by:
getPropertyValue in interface EntityPersister
Throws:
HibernateException

getIdentifier

public Serializable getIdentifier(Object object,
                                  EntityMode entityMode)
                           throws HibernateException
Description copied from interface: ClassMetadata
Get the identifier of an instance (throw an exception if no identifier property)

Specified by:
getIdentifier in interface EntityPersister
Throws:
HibernateException

setIdentifier

public void setIdentifier(Object object,
                          Serializable id,
                          EntityMode entityMode)
                   throws HibernateException
Description copied from interface: ClassMetadata
Set the identifier of an instance (or do nothing if no identifier property)

Specified by:
setIdentifier in interface EntityPersister
Throws:
HibernateException

getVersion

public Object getVersion(Object object,
                         EntityMode entityMode)
                  throws HibernateException
Description copied from interface: ClassMetadata
Get the version number (or timestamp) from the object's version property (or return null if not versioned)

Specified by:
getVersion in interface EntityPersister
Throws:
HibernateException

instantiate

public Object instantiate(Serializable id,
                          EntityMode entityMode)
                   throws HibernateException
Description copied from interface: ClassMetadata
Create a class instance initialized with the given identifier

Specified by:
instantiate in interface EntityPersister
Throws:
HibernateException

isInstance

public boolean isInstance(Object object,
                          EntityMode entityMode)
Description copied from interface: EntityPersister
Is the given object an instance of this entity?

Specified by:
isInstance in interface EntityPersister

hasUninitializedLazyProperties

public boolean hasUninitializedLazyProperties(Object object,
                                              EntityMode entityMode)
Description copied from interface: EntityPersister
Does the given instance have any uninitialized lazy properties?

Specified by:
hasUninitializedLazyProperties in interface EntityPersister

resetIdentifier

public void resetIdentifier(Object entity,
                            Serializable currentId,
                            Object currentVersion,
                            EntityMode entityMode)
Description copied from interface: EntityPersister
Set the identifier and version of the given instance back to its "unsaved" value, returning the id

Specified by:
resetIdentifier in interface EntityPersister
Parameters:
currentId - TODO
currentVersion - TODO

getSubclassEntityPersister

public EntityPersister getSubclassEntityPersister(Object instance,
                                                  SessionFactoryImplementor factory,
                                                  EntityMode entityMode)
Description copied from interface: EntityPersister
Get the persister for an instance of this class or a subclass

Specified by:
getSubclassEntityPersister in interface EntityPersister

guessEntityMode

public EntityMode guessEntityMode(Object object)
Description copied from interface: EntityPersister
Try to discover the entity mode from the entity instance

Specified by:
guessEntityMode in interface EntityPersister

isMultiTable

public boolean isMultiTable()
Description copied from interface: Queryable
Is the inheritence hierarchy described by this persister contained across multiple tables?

Specified by:
isMultiTable in interface Queryable
Returns:
True if the inheritence hierarchy is spread across multiple tables; false otherwise.

getTemporaryIdTableName

public String getTemporaryIdTableName()
Description copied from interface: Queryable
Get the name of the temporary table to be used to (potentially) store id values when performing bulk update/deletes.

Specified by:
getTemporaryIdTableName in interface Queryable
Returns:
The appropriate temporary table name.

getTemporaryIdTableDDL

public String getTemporaryIdTableDDL()
Description copied from interface: Queryable
Get the appropriate DDL command for generating the temporary table to be used to (potentially) store id values when performing bulk update/deletes.

Specified by:
getTemporaryIdTableDDL in interface Queryable
Returns:
The appropriate temporary table creation command.

getPropertySpan

protected int getPropertySpan()

getPropertyValuesToInsert

public Object[] getPropertyValuesToInsert(Object object,
                                          Map mergeMap,
                                          SessionImplementor session)
                                   throws HibernateException
Description copied from interface: ClassMetadata
Return the values of the mapped properties of the object

Specified by:
getPropertyValuesToInsert in interface EntityPersister
Throws:
HibernateException

processInsertGeneratedProperties

public void processInsertGeneratedProperties(Serializable id,
                                             Object entity,
                                             Object[] state,
                                             SessionImplementor session)
Description copied from interface: EntityPersister
Perform a select to retrieve the values of any generated properties back from the database, injecting these generated values into the given entity as well as writing this state to the PersistenceContext.

Note, that because we update the PersistenceContext here, callers need to take care that they have already written the initial snapshot to the PersistenceContext before calling this method.

Specified by:
processInsertGeneratedProperties in interface EntityPersister
Parameters:
id - The entity's id value.
entity - The entity for which to get the state.
state -
session - The session

processUpdateGeneratedProperties

public void processUpdateGeneratedProperties(Serializable id,
                                             Object entity,
                                             Object[] state,
                                             SessionImplementor session)
Description copied from interface: EntityPersister
Perform a select to retrieve the values of any generated properties back from the database, injecting these generated values into the given entity as well as writing this state to the PersistenceContext.

Note, that because we update the PersistenceContext here, callers need to take care that they have already written the initial snapshot to the PersistenceContext before calling this method.

Specified by:
processUpdateGeneratedProperties in interface EntityPersister
Parameters:
id - The entity's id value.
entity - The entity for which to get the state.
state -
session - The session

getIdentifierPropertyName

public String getIdentifierPropertyName()
Description copied from interface: ClassMetadata
Get the name of the identifier property (or return null)

Specified by:
getIdentifierPropertyName in interface EntityPersister

getIdentifierType

public Type getIdentifierType()
Description copied from interface: ClassMetadata
Get the identifier Hibernate type

Specified by:
getIdentifierType in interface EntityPersister

hasSubselectLoadableCollections

public boolean hasSubselectLoadableCollections()
Description copied from interface: EntityPersister
Does this entity own any collections which are fetchable by subselect?

Specified by:
hasSubselectLoadableCollections in interface EntityPersister

getNaturalIdentifierProperties

public int[] getNaturalIdentifierProperties()
Description copied from interface: ClassMetadata
Which properties hold the natural id?

Specified by:
getNaturalIdentifierProperties in interface EntityPersister

getNaturalIdentifierSnapshot

public Object[] getNaturalIdentifierSnapshot(Serializable id,
                                             SessionImplementor session)
                                      throws HibernateException
Description copied from interface: EntityPersister
Retrieve the current state of the natural-id properties from the database.

Specified by:
getNaturalIdentifierSnapshot in interface EntityPersister
Parameters:
id - The identifier of the entity for which to retrieve the naturak-id values.
session - The session from which the request originated.
Returns:
The natural-id snapshot.
Throws:
HibernateException

concretePropertySelectFragmentSansLeadingComma

protected String concretePropertySelectFragmentSansLeadingComma(String alias,
                                                                boolean[] include)

hasNaturalIdentifier

public boolean hasNaturalIdentifier()
Description copied from interface: ClassMetadata
Does this entity declare a natural id?

Specified by:
hasNaturalIdentifier in interface EntityPersister

setPropertyValue

public void setPropertyValue(Object object,
                             String propertyName,
                             Object value,
                             EntityMode entityMode)
                      throws HibernateException
Description copied from interface: ClassMetadata
Set the value of a particular (named) property

Specified by:
setPropertyValue in interface ClassMetadata
Throws:
HibernateException