org.hibernate.persister.entity

Class AbstractEntityPersister

Implemented Interfaces:
ClassMetadata, EntityPersister, Joinable, LazyPropertyInitializer, Loadable, Lockable, OptimisticCacheSource, OuterJoinLoadable, PostInsertIdentityPersister, PropertyMapping, Queryable, SQLLoadable, UniqueKeyLoadable
Known Direct Subclasses:
JoinedSubclassEntityPersister, SingleTableEntityPersister, UnionSubclassEntityPersister

public abstract class AbstractEntityPersister
extends java.lang.Object
implements OuterJoinLoadable, Queryable, ClassMetadata, UniqueKeyLoadable, SQLLoadable, LazyPropertyInitializer, PostInsertIdentityPersister, Lockable

Basic functionality for persisting an entity via JDBC through either generated or custom SQL
Author:
Gavin King

Nested Class Summary

protected static interface
AbstractEntityPersister.InclusionChecker

Field Summary

static String
ENTITY_CLASS
protected String[]
customSQLDelete
protected String[]
customSQLInsert
protected String[]
customSQLUpdate
protected boolean[]
deleteCallable
protected ExecuteUpdateResultCheckStyle[]
deleteResultCheckStyles
protected boolean[]
insertCallable
protected ExecuteUpdateResultCheckStyle[]
insertResultCheckStyles
protected BasicEntityPropertyMapping
propertyMapping
protected String
rowIdName
protected boolean[]
updateCallable
protected ExecuteUpdateResultCheckStyle[]
updateResultCheckStyles

Fields inherited from interface org.hibernate.persister.entity.EntityPersister

ENTITY_ID

Fields inherited from interface org.hibernate.intercept.LazyPropertyInitializer

UNFETCHED_PROPERTY

Fields inherited from interface org.hibernate.persister.entity.Loadable

ROWID_ALIAS

Constructor Summary

AbstractEntityPersister(PersistentClass persistentClass, EntityRegionAccessStrategy cacheAccessStrategy, 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
boolean
canExtractIdOutOfEntity()
Determine whether detahced instances of this entity carry their own identifier value.
protected boolean
check(int rows, Serializable id, int tableNumber, Expectation expectation, PreparedStatement statement)
protected String
concretePropertySelectFragment(String alias, boolean[] includeProperty)
protected String
concretePropertySelectFragment(String alias, ValueInclusion[] inclusions)
protected String
concretePropertySelectFragment(String alias, AbstractEntityPersister.InclusionChecker inclusionChecker)
protected String
concretePropertySelectFragmentSansLeadingComma(String alias, boolean[] include)
boolean
consumesCollectionAlias()
Very, very, very ugly...
boolean
consumesEntityAlias()
Very, very, very ugly...
int
countSubclassProperties()
protected UniqueEntityLoader
createEntityLoader(LockMode lockMode)
protected UniqueEntityLoader
createEntityLoader(LockMode lockMode, Map enabledFilters)
protected String
createFrom(int tableNumber, String alias)
protected JoinFragment
createJoin(String name, boolean innerJoin, boolean includeSubclasses)
protected JoinFragment
createJoin(int[] tableNumbers, String drivingAlias)
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, 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 int
dehydrate(Serializable id, Object[] fields, boolean[] includeProperty, boolean[][] includeColumns, int j, PreparedStatement st, SessionImplementor session)
void
delete(Serializable id, Object version, Object object, SessionImplementor session)
Delete an object
protected void
delete(Serializable id, Object version, int j, Object object, String sql, SessionImplementor session, Object[] loadedState)
Perform an SQL DELETE
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.
Object
forceVersionIncrement(Serializable id, Object currentVersion, SessionImplementor session)
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
generateIdentityInsertString(boolean[] includeProperty)
Used to generate an insery statement against the root table in the case of identifier generation strategies where the insert statement executions actually generates the identifier value.
protected String
generateInsertGeneratedValuesSelectString()
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
generateInsertString(boolean[] includeProperty, int j)
protected String
generateLazySelectString()
protected LockingStrategy
generateLocker(LockMode lockMode)
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, Object[] oldFields, boolean useRowId)
Generate the SQL that updates a row by id (and version)
protected String
generateUpdateString(boolean[] includeProperty, int j, boolean useRowId)
EntityRegionAccessStrategy
getCacheAccessStrategy()
Get the cache (optional operation)
CacheEntryStructure
getCacheEntryStructure()
Get the cache structure
CascadeStyle
getCascadeStyle(int i)
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)
String
getDiscriminatorColumnName()
protected String
getDiscriminatorFormulaTemplate()
EntityMetamodel
getEntityMetamodel()
Retrieve the underlying entity metamodel instance...
String
getEntityName()
The name of the entity
EntityType
getEntityType()
SessionFactoryImplementor
getFactory()
Return the SessionFactory to which this persister "belongs".
FetchMode
getFetchMode(int i)
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)
String[]
getIdentifierColumnNames()
Get the names of columns used to persist the identifier
protected int
getIdentifierColumnSpan()
IdentifierGenerator
getIdentifierGenerator()
Determine which identifier generation strategy is used for this entity.
String
getIdentifierPropertyName()
Get the name of the identifier property (or return null)
Type
getIdentifierType()
Get the identifier Hibernate type
String
getIdentitySelectString()
Get the database-specific SQL command to retrieve the last generated IDENTITY value.
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)
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(String propertyName)
String[]
getPropertyColumnNames(int i)
protected int
getPropertyColumnSpan(int i)
int
getPropertyIndex(String propertyName)
Get the property number of the unique key property
ValueInclusion[]
getPropertyInsertGenerationInclusions()
Which of the properties of this class are database generated values on insert?
boolean[]
getPropertyInsertability()
Get the "insertability" of the properties of this class (does the property appear in an SQL 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
ValueInclusion[]
getPropertyUpdateGenerationInclusions()
Which of the properties of this class are database generated values on update?
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!)
Object
getPropertyValue(Object object, String propertyName, EntityMode entityMode)
Get the value of a particular (named) property
Object
getPropertyValue(Object object, int i, EntityMode entityMode)
Get the value of a particular 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 entity are persisted, for instances of this class and its subclasses.
String
getRootEntityName()
Returns an object that identifies the space in which identifiers of this entity hierarchy are unique.
String
getRootTableAlias(String drivingAlias)
Get the SQL alias this persister would use for the root table given the passed driving alias.
String[]
getRootTableIdentifierColumnNames()
Get the names of columns on the root table used to persist the identifier.
String[]
getRootTableKeyColumnNames()
The names of the primary key columns in the root table.
String
getRootTableName()
Locks are always applied to the "root table".
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)
String
getSelectByUniqueKeyString(String propertyName)
Get a SQL select string that performs a select based on a unique key determined by the given property name).
protected String
getSequentialSelect(String entityName)
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(String propertyName)
Return the column names used to persist/query the named property of the class or a subclass (optional operation).
String[]
getSubclassPropertyColumnNames(int i)
Declarer
getSubclassPropertyDeclarer(String propertyPath)
Determine whether the given property is declared by our mapped class, our super class, or one of our subclasses...
protected String[][]
getSubclassPropertyFormulaTemplateClosure()
String
getSubclassPropertyName(int i)
protected String[]
getSubclassPropertyNameClosure()
protected String[]
getSubclassPropertySubclassNameClosure()
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.
protected abstract int
getSubclassPropertyTableNumber(int i)
Type
getSubclassPropertyType(int i)
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()
For versioned entities, get the name of the column (again, expected on the root table) used to store the version values.
Comparator
getVersionComparator()
int
getVersionProperty()
Get the index of the version property
protected String
getVersionSelectString()
VersionType
getVersionType()
If EntityPersister.isVersioned(), then what is the type of the property holding the locking value.
protected String
getVersionedTableName()
EntityMode
guessEntityMode(Object object)
Try to discover the entity mode from the entity instance
boolean
hasCache()
Does this class have a cache.
boolean
hasCascades()
Determine whether this entity has any non-none cascading.
boolean
hasCollections()
Determine whether this entity contains references to persistent collections.
protected boolean
hasEmbeddedCompositeIdentifier()
protected boolean
hasFormulaProperties()
boolean
hasIdentifierProperty()
Does this class have an identifier property?
boolean
hasInsertGeneratedProperties()
Does this entity define any properties as being database generated on insert?
boolean
hasLazyProperties()
Determine whether this entity defines any lazy properties (ala bytecode instrumentation).
boolean
hasMutableProperties()
Determine whether any properties of this entity are considered mutable.
boolean
hasNaturalIdentifier()
Does this entity declare a natural id?
boolean
hasProxy()
Does this class support dynamic proxies?
boolean
hasRowId()
boolean
hasSequentialSelect()
boolean
hasSubclasses()
Does this entity have mapped subclasses?
boolean
hasSubselectLoadableCollections()
Determine whether this entity contains references to persistent 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?
protected void
initLockers()
protected void
initPropertyPaths(Mapping mapping)
protected void
initSubclassPropertyAliasesMap(PersistentClass model)
Must be called by subclasses, at the end of their constructors
Object
initializeLazyProperty(String fieldName, Object entity, SessionImplementor session)
Initialize the property, and return its new value
Serializable
insert(Object[] fields, Object object, SessionImplementor session)
Persist an instance, using a natively generated identifier (optional operation)
protected Serializable
insert(Object[] fields, boolean[] notNull, String sql, Object object, SessionImplementor session)
Perform an SQL INSERT, and then retrieve a generated identifier.
void
insert(Serializable id, Object[] fields, Object object, SessionImplementor session)
Persist an instance
protected void
insert(Serializable id, Object[] fields, boolean[] notNull, int j, String sql, Object object, SessionImplementor session)
Perform an SQL INSERT.
Object
instantiate(Serializable id, EntityMode entityMode)
Create a class instance initialized with the given identifier
boolean
isAbstract()
Is this an abstract class?
boolean
isBatchLoadable()
Is batch loading enabled?
boolean
isBatchable()
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)
protected boolean
isDeleteCallable(int j)
boolean
isExplicitPolymorphism()
Is this class explicit polymorphism only?
boolean
isIdentifierAssignedByInsert()
Are identifiers of this entity assigned known before the insert execution? Or, are they generated (in the database) by the insert execution.
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)
Determine whether the given name represents a subclass entity (or this entity itself) of the entity mapped by this persister.
protected boolean
isSubclassPropertyDeferred(String propertyName, String entityName)
boolean
isSubclassPropertyNullable(int i)
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
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?
boolean
isVersioned()
Are instances of this class versioned by a timestamp or version number column?
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 (optional operation)
protected void
logStaticSQL()
String
oneToManyFilterFragment(String alias)
protected int
optimisticLockMode()
protected void
postConstruct(Mapping mapping)
void
postInstantiate()
Finish the initialization of this object.
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(String alias, String suffix)
All columns to select, when loading.
String
selectFragment(Joinable rhs, String rhsAlias, String lhsAlias, String entitySuffix, String collectionSuffix, boolean includeCollectionColumns)
All columns to select, when loading.
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, String propertyName, Object value, EntityMode entityMode)
Set the value of a particular (named) property
void
setPropertyValue(Object object, int i, Object value, EntityMode entityMode)
Set the value of a particular 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 alias, String propertyName)
Given a query alias and a property path, return the qualified column name
String[]
toColumns(String name, int i)
String
toString()
Type
toType(String propertyName)
Given a component path expression, get the type of the property
protected boolean
update(Serializable id, Object[] fields, Object[] oldFields, Object rowId, boolean[] includeProperty, int j, Object oldVersion, Object object, String sql, SessionImplementor session)
void
update(Serializable id, Object[] fields, int[] dirtyFields, boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object object, Object rowId, SessionImplementor session)
Update an object
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)

Field Details

ENTITY_CLASS

public static final String ENTITY_CLASS

customSQLDelete

protected String[] customSQLDelete

customSQLInsert

protected String[] customSQLInsert

customSQLUpdate

protected String[] customSQLUpdate

deleteCallable

protected boolean[] deleteCallable

deleteResultCheckStyles

protected ExecuteUpdateResultCheckStyle[] deleteResultCheckStyles

insertCallable

protected boolean[] insertCallable

insertResultCheckStyles

protected ExecuteUpdateResultCheckStyle[] insertResultCheckStyles

propertyMapping

protected final BasicEntityPropertyMapping propertyMapping

rowIdName

protected final String rowIdName

updateCallable

protected boolean[] updateCallable

updateResultCheckStyles

protected ExecuteUpdateResultCheckStyle[] updateResultCheckStyles

Constructor Details

AbstractEntityPersister

public AbstractEntityPersister(PersistentClass persistentClass,
                               EntityRegionAccessStrategy cacheAccessStrategy,
                               SessionFactoryImplementor factory)
            throws HibernateException

Method Details

addDiscriminatorToInsert

protected void addDiscriminatorToInsert(Insert insert)

addDiscriminatorToSelect

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

afterInitialize

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

afterReassociate

public void afterReassociate(Object entity,
                             SessionImplementor session)
Called just after the entity has been reassociated with the session
Specified by:
afterReassociate in interface EntityPersister

canExtractIdOutOfEntity

public boolean canExtractIdOutOfEntity()
Determine whether detahced instances of this entity carry their own identifier value.

The other option is the deperecated feature where users could supply the id during session calls.

Specified by:
canExtractIdOutOfEntity in interface EntityPersister
Returns:
True if either (1) EntityPersister.hasIdentifierProperty() or (2) the identifier is an embedded composite identifier; false otherwise.

check

protected boolean check(int rows,
                        Serializable id,
                        int tableNumber,
                        Expectation expectation,
                        PreparedStatement statement)
            throws HibernateException

concretePropertySelectFragment

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

concretePropertySelectFragment

protected String concretePropertySelectFragment(String alias,
                                                ValueInclusion[] inclusions)

concretePropertySelectFragment

protected String concretePropertySelectFragment(String alias,
                                                AbstractEntityPersister.InclusionChecker inclusionChecker)

concretePropertySelectFragmentSansLeadingComma

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

consumesCollectionAlias

public boolean consumesCollectionAlias()
Very, very, very ugly...
Specified by:
consumesCollectionAlias in interface Joinable
Returns:
Does this persister "consume" collection column aliases in the result set?

consumesEntityAlias

public boolean consumesEntityAlias()
Very, very, very ugly...
Specified by:
consumesEntityAlias in interface Joinable
Returns:
Does this persister "consume" entity column aliases in the result set?

countSubclassProperties

public int countSubclassProperties()
Specified by:
countSubclassProperties in interface OuterJoinLoadable

createEntityLoader

protected UniqueEntityLoader createEntityLoader(LockMode lockMode)
            throws MappingException

createEntityLoader

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

createFrom

protected String createFrom(int tableNumber,
                            String alias)

createJoin

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

createJoin

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

createProxy

public Object createProxy(Serializable id,
                          SessionImplementor session)
            throws HibernateException
Create a new proxy instance
Specified by:
createProxy in interface EntityPersister

createQueryLoader

protected void createQueryLoader()

createSelect

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

createUniqueKeyLoaders

protected void createUniqueKeyLoaders()
            throws MappingException

createWhereByKey

protected String createWhereByKey(int tableNumber,
                                  String alias)

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

dehydrate

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

delete

public void delete(Serializable id,
                   Object version,
                   Object object,
                   SessionImplementor session)
            throws HibernateException
Delete an object
Specified by:
delete in interface EntityPersister

delete

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

filterFragment

protected abstract String filterFragment(String alias)
            throws MappingException

filterFragment

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

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

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

forceVersionIncrement

public Object forceVersionIncrement(Serializable id,
                                    Object currentVersion,
                                    SessionImplementor session)
Specified by:
forceVersionIncrement in interface EntityPersister

fromJoinFragment

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

generateDeleteString

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

generateFilterConditionAlias

public String generateFilterConditionAlias(String rootAlias)
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.

generateIdentityInsertString

protected String generateIdentityInsertString(boolean[] includeProperty)
Used to generate an insery statement against the root table in the case of identifier generation strategies where the insert statement executions actually generates the identifier value.
Parameters:
includeProperty - indices of the properties to include in the insert statement.
Returns:
The insert SQL statement string

generateInsertGeneratedValuesSelectString

protected String generateInsertGeneratedValuesSelectString()

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

generateInsertString

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

generateLazySelectString

protected String generateLazySelectString()

generateLocker

protected LockingStrategy generateLocker(LockMode lockMode)

generateSelectVersionString

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

generateSnapshotSelectString

protected String generateSnapshotSelectString()

generateTableAlias

protected String generateTableAlias(String rootAlias,
                                    int tableNumber)

generateUpdateGeneratedValuesSelectString

protected String generateUpdateGeneratedValuesSelectString()

generateUpdateString

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

generateUpdateString

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

getCacheAccessStrategy

public EntityRegionAccessStrategy getCacheAccessStrategy()
Get the cache (optional operation)
Specified by:
getCacheAccessStrategy in interface EntityPersister

getCacheEntryStructure

public CacheEntryStructure getCacheEntryStructure()
Get the cache structure
Specified by:
getCacheEntryStructure in interface EntityPersister

getCascadeStyle

public CascadeStyle getCascadeStyle(int i)
Specified by:
getCascadeStyle in interface OuterJoinLoadable

getClassMetadata

public ClassMetadata getClassMetadata()
Get the user-visible metadata for the class (optional operation)
Specified by:
getClassMetadata in interface EntityPersister

getConcreteProxyClass

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

getCurrentVersion

public Object getCurrentVersion(Serializable id,
                                SessionImplementor session)
            throws HibernateException
Retrieve the version number
Specified by:
getCurrentVersion in interface EntityPersister

getDatabaseSnapshot

public Object[] getDatabaseSnapshot(Serializable id,
                                    SessionImplementor session)
            throws HibernateException
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

getDiscriminatorAlias

protected String getDiscriminatorAlias()

getDiscriminatorAlias

public String getDiscriminatorAlias(String suffix)
Specified by:
getDiscriminatorAlias in interface Loadable

getDiscriminatorColumnName

public String getDiscriminatorColumnName()
Specified by:
getDiscriminatorColumnName in interface Loadable

getDiscriminatorFormulaTemplate

protected String getDiscriminatorFormulaTemplate()

getEntityMetamodel

public EntityMetamodel getEntityMetamodel()
Retrieve the underlying entity metamodel instance...
Specified by:
getEntityMetamodel in interface EntityPersister
Returns:
The metamodel

getEntityName

public final String getEntityName()
The name of the entity
Specified by:
getEntityName in interface EntityPersister
getEntityName in interface ClassMetadata

getEntityType

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

getFactory

public SessionFactoryImplementor getFactory()
Return the SessionFactory to which this persister "belongs".
Specified by:
getFactory in interface EntityPersister
Returns:
The owning SessionFactory.

getFetchMode

public FetchMode getFetchMode(int i)
Specified by:
getFetchMode in interface OuterJoinLoadable

getIdentifier

public Serializable getIdentifier(Object object,
                                  EntityMode entityMode)
            throws HibernateException
Get the identifier of an instance (throw an exception if no identifier property)
Specified by:
getIdentifier in interface EntityPersister
getIdentifier in interface ClassMetadata

getIdentifierAliases

protected String[] getIdentifierAliases()

getIdentifierAliases

public String[] getIdentifierAliases(String suffix)
Specified by:
getIdentifierAliases in interface Loadable

getIdentifierColumnNames

public String[] getIdentifierColumnNames()
Get the names of columns used to persist the identifier
Specified by:
getIdentifierColumnNames in interface Loadable
getIdentifierColumnNames in interface Queryable

getIdentifierColumnSpan

protected int getIdentifierColumnSpan()

getIdentifierGenerator

public IdentifierGenerator getIdentifierGenerator()
            throws HibernateException
Determine which identifier generation strategy is used for this entity.
Specified by:
getIdentifierGenerator in interface EntityPersister
Returns:
The identifier generation strategy.

getIdentifierPropertyName

public String getIdentifierPropertyName()
Get the name of the identifier property (or return null)
Specified by:
getIdentifierPropertyName in interface EntityPersister
getIdentifierPropertyName in interface ClassMetadata

getIdentifierType

public Type getIdentifierType()
Get the identifier Hibernate type
Specified by:
getIdentifierType in interface EntityPersister
getIdentifierType in interface ClassMetadata

getIdentitySelectString

public String getIdentitySelectString()
Get the database-specific SQL command to retrieve the last generated IDENTITY value.
Specified by:
getIdentitySelectString in interface PostInsertIdentityPersister
Returns:
The SQL command string

getKeyColumnNames

public String[] getKeyColumnNames()
The columns to join on
Specified by:
getKeyColumnNames in interface Joinable

getKeyColumns

protected abstract String[] getKeyColumns(int j)

getLazyProperties

protected Set getLazyProperties()

getMappedClass

public final Class getMappedClass(EntityMode entityMode)
The persistent class, or null
Specified by:
getMappedClass in interface EntityPersister
getMappedClass in interface ClassMetadata

getMappedSuperclass

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

getName

public String getName()
An identifying name; a class name or collection role name.
Specified by:
getName in interface Joinable

getNaturalIdentifierProperties

public int[] getNaturalIdentifierProperties()
Which properties hold the natural id?
Specified by:
getNaturalIdentifierProperties in interface EntityPersister
getNaturalIdentifierProperties in interface ClassMetadata

getNaturalIdentifierSnapshot

public Object[] getNaturalIdentifierSnapshot(Serializable id,
                                             SessionImplementor session)
            throws HibernateException
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.

getNonLazyPropertyUpdateability

public boolean[] getNonLazyPropertyUpdateability()

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

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

getPropertyAliases

public String[] getPropertyAliases(String suffix,
                                   int i)
Specified by:
getPropertyAliases in interface Loadable

getPropertyCascadeStyles

public CascadeStyle[] getPropertyCascadeStyles()
Get the cascade styles of the propertes (optional operation)
Specified by:
getPropertyCascadeStyles in interface EntityPersister

getPropertyCheckability

public boolean[] getPropertyCheckability()
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

getPropertyColumnNames

public String[] getPropertyColumnNames(String propertyName)
Specified by:
getPropertyColumnNames in interface OuterJoinLoadable

getPropertyColumnNames

public String[] getPropertyColumnNames(int i)
Specified by:
getPropertyColumnNames in interface Loadable

getPropertyColumnSpan

protected int getPropertyColumnSpan(int i)

getPropertyIndex

public int getPropertyIndex(String propertyName)
Get the property number of the unique key property
Specified by:
getPropertyIndex in interface UniqueKeyLoadable

getPropertyInsertGenerationInclusions

public ValueInclusion[] getPropertyInsertGenerationInclusions()
Which of the properties of this class are database generated values on insert?
Specified by:
getPropertyInsertGenerationInclusions in interface EntityPersister

getPropertyInsertability

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

getPropertyLaziness

public boolean[] getPropertyLaziness()
Get the "laziness" of the properties of this class
Specified by:
getPropertyLaziness in interface EntityPersister
getPropertyLaziness in interface ClassMetadata

getPropertyNames

public String[] getPropertyNames()
Get the names of the class' persistent properties
Specified by:
getPropertyNames in interface EntityPersister
getPropertyNames in interface ClassMetadata

getPropertyNullability

public boolean[] getPropertyNullability()
Get the nullability of the class' persistent properties
Specified by:
getPropertyNullability in interface EntityPersister
getPropertyNullability in interface ClassMetadata

getPropertySpan

protected int getPropertySpan()

getPropertySubclassNames

protected String[] getPropertySubclassNames()

getPropertyTableNumbers

protected abstract int[] getPropertyTableNumbers()

getPropertyTableNumbersInSelect

protected abstract int[] getPropertyTableNumbersInSelect()

getPropertyType

public Type getPropertyType(String propertyName)
            throws MappingException
Get the type of a particular (named) property
Specified by:
getPropertyType in interface EntityPersister
getPropertyType in interface ClassMetadata

getPropertyTypes

public Type[] getPropertyTypes()
Get the Hibernate types of the class properties
Specified by:
getPropertyTypes in interface EntityPersister
getPropertyTypes in interface ClassMetadata

getPropertyUpdateGenerationInclusions

public ValueInclusion[] getPropertyUpdateGenerationInclusions()
Which of the properties of this class are database generated values on update?
Specified by:
getPropertyUpdateGenerationInclusions in interface EntityPersister

getPropertyUpdateability

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

getPropertyUpdateability

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

getPropertyValue

public Object getPropertyValue(Object object,
                               String propertyName,
                               EntityMode entityMode)
            throws HibernateException
Get the value of a particular (named) property
Specified by:
getPropertyValue in interface EntityPersister
getPropertyValue in interface ClassMetadata

getPropertyValue

public Object getPropertyValue(Object object,
                               int i,
                               EntityMode entityMode)
            throws HibernateException
Get the value of a particular property
Specified by:
getPropertyValue in interface EntityPersister

getPropertyValues

public Object[] getPropertyValues(Object object,
                                  EntityMode entityMode)
            throws HibernateException
Extract the property values from the given entity.
Specified by:
getPropertyValues in interface EntityPersister
getPropertyValues in interface ClassMetadata
Parameters:
entityMode - The entity-mode of the given entity
Returns:
The property values.

getPropertyValuesToInsert

public Object[] getPropertyValuesToInsert(Object object,
                                          Map mergeMap,
                                          SessionImplementor session)
            throws HibernateException
Return the values of the mapped properties of the object
Specified by:
getPropertyValuesToInsert in interface EntityPersister
getPropertyValuesToInsert in interface ClassMetadata

getPropertyVersionability

public boolean[] getPropertyVersionability()
Get the "versionability" of the properties of this class (is the property optimistic-locked)
Specified by:
getPropertyVersionability in interface EntityPersister

getQuerySpaces

public Serializable[] getQuerySpaces()
Specified by:
getQuerySpaces in interface EntityPersister
Returns:
The query spaces.

getRootEntityName

public String getRootEntityName()
Returns an object that identifies the space in which identifiers of this entity hierarchy are unique. Might be a table name, a JNDI URL, etc.
Specified by:
getRootEntityName in interface EntityPersister
Returns:
The root entity name.

getRootTableAlias

public String getRootTableAlias(String drivingAlias)
Get the SQL alias this persister would use for the root table given the passed driving alias.
Specified by:
getRootTableAlias in interface Lockable
Parameters:
drivingAlias - The driving alias; or the alias for the table mapped by this persister in the hierarchy.
Returns:
The root table alias.

getRootTableIdentifierColumnNames

public String[] getRootTableIdentifierColumnNames()
Get the names of columns on the root table used to persist the identifier.
Specified by:
getRootTableIdentifierColumnNames in interface Lockable
Returns:
The root table identifier column names.

getRootTableKeyColumnNames

public String[] getRootTableKeyColumnNames()
The names of the primary key columns in the root table.
Specified by:
getRootTableKeyColumnNames in interface PostInsertIdentityPersister
Returns:
The primary key column names.

getRootTableName

public String getRootTableName()
Locks are always applied to the "root table".
Specified by:
getRootTableName in interface Lockable
Returns:
The root table name

getSQLDeleteStrings

protected String[] getSQLDeleteStrings()

getSQLIdentityInsertString

protected String getSQLIdentityInsertString()
The query that inserts a row, letting the database generate an id
Returns:
The IDENTITY-based insertion query.

getSQLInsertStrings

protected String[] getSQLInsertStrings()

getSQLLazySelectString

protected String getSQLLazySelectString()

getSQLLazyUpdateByRowIdStrings

protected String[] getSQLLazyUpdateByRowIdStrings()

getSQLLazyUpdateStrings

protected String[] getSQLLazyUpdateStrings()

getSQLSnapshotSelectString

protected String getSQLSnapshotSelectString()

getSQLUpdateByRowIdStrings

protected String[] getSQLUpdateByRowIdStrings()

getSQLUpdateStrings

protected String[] getSQLUpdateStrings()

getSQLWhereString

protected String getSQLWhereString(String alias)

getSelectByUniqueKeyString

public String getSelectByUniqueKeyString(String propertyName)
Get a SQL select string that performs a select based on a unique key determined by the given property name).
Specified by:
getSelectByUniqueKeyString in interface PostInsertIdentityPersister
Parameters:
propertyName - The name of the property which maps to the column(s) to use in the select statement restriction.
Returns:
The SQL select string

getSequentialSelect

protected String getSequentialSelect(String entityName)

getSubclassColumnAliasClosure

protected String[] getSubclassColumnAliasClosure()

getSubclassColumnClosure

protected String[] getSubclassColumnClosure()

getSubclassColumnLazyiness

protected boolean[] getSubclassColumnLazyiness()

getSubclassColumnTableNumberClosure

protected abstract int[] getSubclassColumnTableNumberClosure()

getSubclassEntityPersister

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

getSubclassFormulaAliasClosure

protected String[] getSubclassFormulaAliasClosure()

getSubclassFormulaClosure

protected String[] getSubclassFormulaClosure()

getSubclassFormulaLazyiness

protected boolean[] getSubclassFormulaLazyiness()

getSubclassFormulaTableNumberClosure

protected abstract int[] getSubclassFormulaTableNumberClosure()

getSubclassFormulaTemplateClosure

protected String[] getSubclassFormulaTemplateClosure()

getSubclassPropertyColumnAliases

public 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).
Specified by:
getSubclassPropertyColumnAliases in interface SQLLoadable

getSubclassPropertyColumnNameClosure

protected String[][] getSubclassPropertyColumnNameClosure()

getSubclassPropertyColumnNames

public String[] getSubclassPropertyColumnNames(String propertyName)
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

getSubclassPropertyColumnNames

public String[] getSubclassPropertyColumnNames(int i)
Specified by:
getSubclassPropertyColumnNames in interface OuterJoinLoadable

getSubclassPropertyDeclarer

public Declarer getSubclassPropertyDeclarer(String propertyPath)
Specified by:
getSubclassPropertyDeclarer in interface Queryable
Parameters:
propertyPath - The property name.
Returns:
The property declarer

getSubclassPropertyFormulaTemplateClosure

protected String[][] getSubclassPropertyFormulaTemplateClosure()

getSubclassPropertyName

public String getSubclassPropertyName(int i)
Specified by:
getSubclassPropertyName in interface OuterJoinLoadable

getSubclassPropertyNameClosure

protected String[] getSubclassPropertyNameClosure()

getSubclassPropertySubclassNameClosure

protected String[] getSubclassPropertySubclassNameClosure()

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

getSubclassPropertyTableNumber

protected abstract int getSubclassPropertyTableNumber(int i)

getSubclassPropertyType

public Type getSubclassPropertyType(int i)
Specified by:
getSubclassPropertyType in interface OuterJoinLoadable

getSubclassPropertyTypeClosure

protected Type[] getSubclassPropertyTypeClosure()

getSubclassTableKeyColumns

protected abstract String[] getSubclassTableKeyColumns(int j)

getSubclassTableName

public abstract String getSubclassTableName(int j)
Get the name of the table with the given index from the internal array.
Specified by:
getSubclassTableName in interface Queryable
Parameters:
Returns:

getSubclassTableSpan

protected abstract int getSubclassTableSpan()

getTableName

protected abstract String getTableName(int j)

getTableSpan

protected abstract int getTableSpan()

getTableUpdateNeeded

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

The return here is an array of boolean values with each index corresponding to a given table in the scope of this persister.

Parameters:
dirtyProperties - The indices of all the entity properties considered dirty.
hasDirtyCollection - Whether any collections owned by the entity which were considered dirty.
Returns:
Array of booleans indicating which table require updating.

getTemporaryIdTableDDL

public 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.
Specified by:
getTemporaryIdTableDDL in interface Queryable
Returns:
The appropriate temporary table creation command.

getTemporaryIdTableName

public String getTemporaryIdTableName()
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.

getTuplizer

protected EntityTuplizer getTuplizer(EntityMode entityMode)

getTuplizer

protected EntityTuplizer getTuplizer(SessionImplementor session)

getType

public Type getType()
Get the type
Specified by:
getType in interface PropertyMapping
getType in interface SQLLoadable

getVersion

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

getVersionColumnName

public String getVersionColumnName()
For versioned entities, get the name of the column (again, expected on the root table) used to store the version values.
Specified by:
getVersionColumnName in interface Lockable
Returns:
The version column name.

getVersionComparator

public Comparator getVersionComparator()
Specified by:
getVersionComparator in interface OptimisticCacheSource

getVersionProperty

public int getVersionProperty()
Get the index of the version property
Specified by:
getVersionProperty in interface EntityPersister
getVersionProperty in interface ClassMetadata

getVersionSelectString

protected String getVersionSelectString()

getVersionType

public VersionType getVersionType()
If EntityPersister.isVersioned(), then what is the type of the property holding the locking value.
Specified by:
getVersionType in interface EntityPersister
Returns:
The type of the version property; or null, if not versioned.

getVersionedTableName

protected String getVersionedTableName()

guessEntityMode

public EntityMode guessEntityMode(Object object)
Try to discover the entity mode from the entity instance
Specified by:
guessEntityMode in interface EntityPersister

hasCache

public boolean hasCache()
Does this class have a cache.
Specified by:
hasCache in interface EntityPersister

hasCascades

public boolean hasCascades()
Determine whether this entity has any non-none cascading.
Specified by:
hasCascades in interface EntityPersister
Returns:
True if the entity has any properties with a cscade other than NONE; false otherwise (aka, no cascading).

hasCollections

public boolean hasCollections()
Determine whether this entity contains references to persistent collections.
Specified by:
hasCollections in interface EntityPersister
Returns:
True if the entity does contain persistent collections; false otherwise.

hasEmbeddedCompositeIdentifier

protected boolean hasEmbeddedCompositeIdentifier()

hasFormulaProperties

protected boolean hasFormulaProperties()

hasIdentifierProperty

public boolean hasIdentifierProperty()
Does this class have an identifier property?
Specified by:
hasIdentifierProperty in interface EntityPersister
hasIdentifierProperty in interface ClassMetadata

hasInsertGeneratedProperties

public boolean hasInsertGeneratedProperties()
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).

hasLazyProperties

public boolean hasLazyProperties()
Determine whether this entity defines any lazy properties (ala bytecode instrumentation).
Specified by:
hasLazyProperties in interface EntityPersister
Returns:
True if the entity has properties mapped as lazy; false otherwise.

hasMutableProperties

public boolean hasMutableProperties()
Determine whether any properties of this entity are considered mutable.
Specified by:
hasMutableProperties in interface EntityPersister
Returns:
True if any properties of the entity are mutable; false otherwise (meaning none are).

hasNaturalIdentifier

public boolean hasNaturalIdentifier()
Does this entity declare a natural id?
Specified by:
hasNaturalIdentifier in interface EntityPersister
hasNaturalIdentifier in interface ClassMetadata

hasProxy

public boolean hasProxy()
Does this class support dynamic proxies?
Specified by:
hasProxy in interface EntityPersister
hasProxy in interface ClassMetadata

hasRowId

public boolean hasRowId()
Specified by:
hasRowId in interface Loadable

hasSequentialSelect

public boolean hasSequentialSelect()

hasSubclasses

public boolean hasSubclasses()
Does this entity have mapped subclasses?
Specified by:
hasSubclasses in interface Loadable
hasSubclasses in interface ClassMetadata

hasSubselectLoadableCollections

public boolean hasSubselectLoadableCollections()
Determine whether this entity contains references to persistent collections which are fetchable by subselect?
Specified by:
hasSubselectLoadableCollections in interface EntityPersister
Returns:
True if the entity contains collections fetchable by subselect; false otherwise.

hasUninitializedLazyProperties

public boolean hasUninitializedLazyProperties(Object object,
                                              EntityMode entityMode)
Does the given instance have any uninitialized lazy properties?
Specified by:
hasUninitializedLazyProperties in interface EntityPersister

hasUpdateGeneratedProperties

public boolean hasUpdateGeneratedProperties()
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).

hasWhere

protected boolean hasWhere()

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

identifierSelectFragment

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

implementsLifecycle

public boolean implementsLifecycle(EntityMode entityMode)
Does the class implement the Lifecycle interface?
Specified by:
implementsLifecycle in interface EntityPersister
implementsLifecycle in interface ClassMetadata

implementsValidatable

public boolean implementsValidatable(EntityMode entityMode)
Does the class implement the Validatable interface?
Specified by:
implementsValidatable in interface EntityPersister
implementsValidatable in interface ClassMetadata

initLockers

protected void initLockers()

initPropertyPaths

protected void initPropertyPaths(Mapping mapping)
            throws MappingException

initSubclassPropertyAliasesMap

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

initializeLazyProperty

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

insert

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

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.

This form is used for PostInsertIdentifierGenerator-style ids (IDENTITY, select, etc).


insert

public void insert(Serializable id,
                   Object[] fields,
                   Object object,
                   SessionImplementor session)
            throws HibernateException
Persist an instance
Specified by:
insert in interface EntityPersister

insert

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

This for is used for all non-root tables as well as the root table in cases where the identifier value is known before the insert occurs.


instantiate

public Object instantiate(Serializable id,
                          EntityMode entityMode)
            throws HibernateException
Create a class instance initialized with the given identifier
Specified by:
instantiate in interface EntityPersister
instantiate in interface ClassMetadata

isAbstract

public boolean isAbstract()
Is this an abstract class?
Specified by:
isAbstract in interface Loadable
isAbstract in interface Queryable

isBatchLoadable

public boolean isBatchLoadable()
Is batch loading enabled?
Specified by:
isBatchLoadable in interface EntityPersister

isBatchable

public boolean isBatchable()

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

isClassOrSuperclassTable

protected abstract boolean isClassOrSuperclassTable(int j)

isCollection

public boolean isCollection()
Is this instance actually a CollectionPersister?
Specified by:
isCollection in interface Joinable

isDefinedOnSubclass

public boolean isDefinedOnSubclass(int i)
Specified by:
isDefinedOnSubclass in interface OuterJoinLoadable

isDeleteCallable

protected boolean isDeleteCallable(int j)

isExplicitPolymorphism

public boolean isExplicitPolymorphism()
Is this class explicit polymorphism only?
Specified by:
isExplicitPolymorphism in interface Queryable

isIdentifierAssignedByInsert

public boolean isIdentifierAssignedByInsert()
Are identifiers of this entity assigned known before the insert execution? Or, are they generated (in the database) by the insert execution.
Specified by:
isIdentifierAssignedByInsert in interface EntityPersister
Returns:
True if identifiers for this entity are generated by the insert execution.

isInherited

public boolean isInherited()
Does this entity extend a mapped superclass?
Specified by:
isInherited in interface EntityPersister
isInherited in interface ClassMetadata

isInsertCallable

protected boolean isInsertCallable(int j)

isInstance

public boolean isInstance(Object object,
                          EntityMode entityMode)
Is the given object an instance of this entity?
Specified by:
isInstance in interface EntityPersister

isInstrumented

public boolean isInstrumented(EntityMode entityMode)
Has the class actually been bytecode instrumented?
Specified by:
isInstrumented in interface EntityPersister

isInverseSubclassTable

protected boolean isInverseSubclassTable(int j)

isInverseTable

protected boolean isInverseTable(int j)

isLazyPropertiesCacheable

public boolean isLazyPropertiesCacheable()
Should lazy properties of this entity be cached?
Specified by:
isLazyPropertiesCacheable in interface EntityPersister

isMultiTable

public boolean isMultiTable()
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.

isMutable

public boolean isMutable()
Are instances of this class mutable?
Specified by:
isMutable in interface EntityPersister
isMutable in interface ClassMetadata

isNullableSubclassTable

protected boolean isNullableSubclassTable(int j)

isNullableTable

protected boolean isNullableTable(int j)

isPolymorphic

public boolean isPolymorphic()

isPropertyOfTable

protected abstract boolean isPropertyOfTable(int property,
                                             int j)

isSelectBeforeUpdateRequired

public boolean isSelectBeforeUpdateRequired()
Is select snapshot before update enabled?
Specified by:
isSelectBeforeUpdateRequired in interface EntityPersister

isSubclassEntityName

public boolean isSubclassEntityName(String entityName)
Determine whether the given name represents a subclass entity (or this entity itself) of the entity mapped by this persister.
Specified by:
isSubclassEntityName in interface EntityPersister
Parameters:
entityName - The entity name to be checked.
Returns:
True if the given entity name represents either the entity mapped by this persister or one of its subclass entities; false otherwise.

isSubclassPropertyDeferred

protected boolean isSubclassPropertyDeferred(String propertyName,
                                             String entityName)

isSubclassPropertyNullable

public boolean isSubclassPropertyNullable(int i)
Specified by:
isSubclassPropertyNullable in interface OuterJoinLoadable

isSubclassTableLazy

protected boolean isSubclassTableLazy(int j)

isSubclassTableSequentialSelect

protected boolean isSubclassTableSequentialSelect(int j)

isTableCascadeDeleteEnabled

protected abstract boolean isTableCascadeDeleteEnabled(int j)

isTransient

public Boolean isTransient(Object entity,
                           SessionImplementor session)
            throws HibernateException
Is this a new transient instance?
Specified by:
isTransient in interface EntityPersister

isUpdateCallable

protected boolean isUpdateCallable(int j)

isVersionPropertyGenerated

public boolean isVersionPropertyGenerated()
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()
Is the version property included in insert statements?
Specified by:
isVersionPropertyInsertable in interface Queryable

isVersioned

public boolean isVersioned()
Are instances of this class versioned by a timestamp or version number column?
Specified by:
isVersioned in interface EntityPersister
isVersioned in interface OptimisticCacheSource
isVersioned in interface ClassMetadata

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

loadByUniqueKey

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

lock

public void lock(Serializable id,
                 Object version,
                 Object object,
                 LockMode lockMode,
                 SessionImplementor session)
            throws HibernateException
Do a version check (optional operation)
Specified by:
lock in interface EntityPersister

logStaticSQL

protected void logStaticSQL()

oneToManyFilterFragment

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

optimisticLockMode

protected final int optimisticLockMode()

postConstruct

protected void postConstruct(Mapping mapping)
            throws MappingException

postInstantiate

public void postInstantiate()
            throws MappingException
Finish the initialization of this object.

Called only once per SessionFactory lifecycle, after all entity persisters have been instantiated.

Specified by:
postInstantiate in interface EntityPersister
Throws:
MappingException - Indicates an issue in the metdata.

processInsertGeneratedProperties

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

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)
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

propertySelectFragment

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

renderSelect

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

resetIdentifier

public 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
Specified by:
resetIdentifier in interface EntityPersister
Parameters:
currentId - TODO
currentVersion - TODO

selectFragment

public String selectFragment(String alias,
                             String suffix)
All columns to select, when loading.
Specified by:
selectFragment in interface OuterJoinLoadable
selectFragment in interface SQLLoadable

selectFragment

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

setIdentifier

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

setPropertyValue

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

setPropertyValue

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

setPropertyValues

public void setPropertyValues(Object object,
                              Object[] values,
                              EntityMode entityMode)
            throws HibernateException
Set the given values to the mapped properties of the given object
Specified by:
setPropertyValues in interface EntityPersister
setPropertyValues in interface ClassMetadata

toColumns

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

toColumns

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

toColumns

public String[] toColumns(String name,
                          int i)
Specified by:
toColumns in interface OuterJoinLoadable

toString

public String toString()

toType

public Type toType(String propertyName)
            throws QueryException
Given a component path expression, get the type of the property
Specified by:
toType in interface PropertyMapping

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

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

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

useDynamicInsert

protected boolean useDynamicInsert()

useDynamicUpdate

protected boolean useDynamicUpdate()

useGetGeneratedKeys

protected boolean useGetGeneratedKeys()

useInsertSelectIdentity

protected boolean useInsertSelectIdentity()

whereJoinFragment

public String whereJoinFragment(String alias,
                                boolean innerJoin,
                                boolean includeSubclasses)
Get the where clause part of any joins (optional operation)
Specified by:
whereJoinFragment in interface Joinable