站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

EntityPersister (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.persister
Class EntityPersister

java.lang.Object
  extended bynet.sf.hibernate.persister.AbstractPropertyMapping
      extended bynet.sf.hibernate.persister.AbstractEntityPersister
          extended bynet.sf.hibernate.persister.EntityPersister
All Implemented Interfaces:
ClassMetadata, ClassPersister, Joinable, Loadable, OuterJoinLoadable, PropertyMapping, Queryable, SQLLoadable, UniqueKeyLoadable

public class EntityPersister
extends AbstractEntityPersister
implements Queryable

The default implementation of the ClassPersister interface. Implements the "table-per-class-hierarchy" mapping strategy for an entity class.

Author:
Gavin King

Field Summary
 
Fields inherited from class net.sf.hibernate.persister.AbstractEntityPersister
ENTITY_CLASS
 
Fields inherited from interface net.sf.hibernate.persister.ClassPersister
ENTITY_ID
 
Constructor Summary
EntityPersister(PersistentClass model, SessionFactoryImplementor factory)
           
 
Method Summary
 int countSubclassProperties()
          How many properties are there, for this class and all subclasses.
protected  int dehydrate(Serializable id, Object[] fields, boolean[] includeProperty, PreparedStatement st, SessionImplementor session)
          Marshall the fields of a persistent instance to a prepared statement
 void delete(Serializable id, Object version, Object object, SessionImplementor session)
          Delete an object
 int enableJoinedFetch(int i)
          May this property be fetched using an SQL outerjoin.
 String fromJoinFragment(String alias, boolean innerJoin, boolean includeSubclasses)
          Get the from clause part of any joins (optional operation)
 String fromTableFragment(String name)
          Get the main from table fragment, given a query alias.
protected  String generateConcreteSelectString(boolean[] includeProperty)
          Generate the SQL that selects a row by id, excluding subclasses
protected  String generateDeleteString()
          Generate the SQL that deletes a row by id (and version)
protected  String generateInsertString(boolean identityInsert, boolean[] includeProperty)
          Generate the SQL that inserts a row
protected  String generateLockString()
          Generate the SQL that pessimistic locks a row by id (and version)
protected  String generateSelectForUpdateNowaitString()
          Generate the SQL that selects a row by id using FOR UPDATE
protected  String generateSelectForUpdateString()
          Generate the SQL that selects a row by id using FOR UPDATE
protected  String generateSelectString()
          Generate the SQL that selects a row by id
protected  String generateUpdateString(boolean[] includeProperty)
          Generate the SQL that updates a row by id (and version)
protected  String generateUpdateString(boolean[] includeProperty, Object[] oldFields)
           
protected  String[] getActualPropertyColumnNames(int i)
           
protected  String getConcreteSelectString()
           
 String getDiscriminatorAlias()
           
 String getDiscriminatorColumnName()
          Get the name of the column used as a discriminator
 Object getDiscriminatorSQLValue()
          Get the discriminator value for this particular concrete subclass, as a string that may be embedded in a select statement
 Type getDiscriminatorType()
          Get the discriminator type
protected  String getFormulaTemplate(int i)
           
 String[] getPropertyColumnNames(int i)
          Get the column names for the numbered property of this class
 Serializable[] getPropertySpaces()
          Returns an array of objects that identify spaces in which properties of this class instance are persisted.
protected  String getSQLDeleteString()
          The query that deletes a row by id (and version)
protected  String getSQLIdentityInsertString()
          The query that inserts a row, letting the database generate an id
protected  String getSQLInsertString()
          The query that inserts a row with a given id
protected  String getSQLUpdateString()
          The query that updates a row by id (and version)
 Class[] getSubclassClosure()
           
 Class getSubclassForDiscriminatorValue(Object value)
          Get the concrete subclass corresponding to the given discriminator value
 String[] getSubclassPropertyColumnNames(int i)
          Return the column names used to persist the numbered property of the class or a subclass.
 String getSubclassPropertyName(int i)
          Get the name of the numbered property of the class or a subclass.
 String getSubclassPropertyTableName(int i)
          Return the table name used to persist the numbered property of the class or a subclass.
 Type getSubclassPropertyType(int i)
          Get the type of the numbered property of the class or a subclass.
 String getTableName()
          The table to join to.
protected  String getVersionedTableName()
           
protected  String getVersionSelectString()
           
 Serializable insert(Object[] fields, boolean[] notNull, String sql, Object object, SessionImplementor session)
          Persist an object, using a natively generated identifier
 Serializable insert(Object[] fields, Object object, SessionImplementor session)
          Persist an instance, using a natively generated identifier (optional operation)
 void insert(Serializable id, Object[] fields, boolean[] notNull, String sql, Object object, SessionImplementor session)
          Persist an object
 void insert(Serializable id, Object[] fields, Object object, SessionImplementor session)
          Persist an instance
 boolean isCacheInvalidationRequired()
          Should we always invalidate the cache instead of recaching updated state
 boolean isDefinedOnSubclass(int i)
          Is this property defined on a subclass of the mapped class.
 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
 void postInstantiate()
          Finish the initialization of this object, once all ClassPersisters have been instantiated.
 String propertySelectFragment(String name, String suffix)
          Given a query alias and an identifying suffix, render the property select fragment.
 String queryWhereFragment(String name, boolean innerJoin, boolean includeSubclasses)
          Get the where clause fragment, given a query alias
 String[] toColumns(String name, int i)
          Given the number of a property of a subclass, and a table alias, return the aliased column names.
 void update(Serializable id, Object[] fields, int[] dirtyFields, Object[] oldFields, Object oldVersion, Object object, SessionImplementor session)
          Update an object
protected  void update(Serializable id, Object[] fields, Object[] oldFields, boolean[] includeProperty, Object oldVersion, Object object, String sql, SessionImplementor session)
           
 String whereJoinFragment(String alias, boolean innerJoin, boolean includeSubclasses)
          Get the where clause part of any joins (optional operation)
 
Methods inherited from class net.sf.hibernate.persister.AbstractEntityPersister
check, checkColumnDuplication, consumesAlias, convert, createEntityLoader, createProxy, createProxyFactory, createUniqueKeyLoaders, findDirty, findModified, generateSelectVersionString, getCache, getClassMetadata, getClassName, getConcreteProxyClass, getCurrentPersistentState, getCurrentVersion, getDialect, getDiscriminatorAlias, getGeneratedIdentity, getGetters, getHydrateSpan, getIdentifier, getIdentifierAliases, getIdentifierAliases, getIdentifierColumnNames, getIdentifierGenerator, getIdentifierPropertyName, getIdentifierSpace, getIdentifierType, getJoinKeyColumnNames, getMappedClass, getMappedSuperclass, getName, getNotNullInsertableColumns, getPropertiesToUpdate, getPropertyAliases, getPropertyCascadeStyles, getPropertyInsertability, getPropertyNames, getPropertyNullability, getPropertyType, getPropertyTypes, getPropertyUpdateability, getPropertyValue, getPropertyValue, getPropertyValues, getSetters, getSQLWhereString, getSubclassPropertyColumnAliases, getType, getUniqueKeyColumnNames, getVersion, getVersionColumnName, getVersionProperty, getVersionType, hasCache, hasCascades, hasCollections, hasEmbeddedIdentifier, hasIdentifierProperty, hasIdentifierPropertyOrEmbeddedCompositeIdentifier, hasProxy, hasSelectBeforeUpdate, hasSubclasses, hasWhere, identifierSelectFragment, implementsLifecycle, implementsValidatable, initLockers, initPropertyPaths, initSubclassPropertyAliasesMap, instantiate, isBatchable, isBatchLoadable, isCollection, isExplicitPolymorphism, isIdentifierAssignedByInsert, isInherited, isManyToMany, isMutable, isPolymorphic, isUnsaved, isVersioned, loadByUniqueKey, lock, optimisticLockMode, selectFragment, selectFragment, setIdentifier, setPropertyValue, setPropertyValue, setPropertyValues, sqlIdentitySelect, toString, useDynamicInsert, useDynamicUpdate
 
Methods inherited from class net.sf.hibernate.persister.AbstractPropertyMapping
addFormulaPropertyPath, addPropertyPath, handlePath, initComponentPropertyPaths, initIdentifierPropertyPaths, initPropertyPaths, initPropertyPaths, toColumns, toType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.hibernate.persister.Queryable
getIdentifierColumnNames, getMappedSuperclass, identifierSelectFragment, isExplicitPolymorphism, isInherited
 
Methods inherited from interface net.sf.hibernate.persister.Loadable
getDiscriminatorAlias, getIdentifierAliases, getPropertyAliases, hasSubclasses
 
Methods inherited from interface net.sf.hibernate.persister.ClassPersister
createProxy, findDirty, findModified, getCache, getClassMetadata, getClassName, getConcreteProxyClass, getCurrentPersistentState, getCurrentVersion, getIdentifier, getIdentifierGenerator, getIdentifierPropertyName, getIdentifierSpace, getIdentifierType, getMappedClass, getPropertyCascadeStyles, getPropertyInsertability, getPropertyNames, getPropertyNullability, getPropertyType, getPropertyTypes, getPropertyUpdateability, getPropertyValue, getPropertyValue, getPropertyValues, getVersion, getVersionProperty, getVersionType, hasCache, hasCascades, hasCollections, hasIdentifierProperty, hasIdentifierPropertyOrEmbeddedCompositeIdentifier, hasProxy, implementsLifecycle, implementsValidatable, instantiate, isBatchLoadable, isIdentifierAssignedByInsert, isMutable, isUnsaved, isVersioned, lock, setIdentifier, setPropertyValue, setPropertyValues
 
Methods inherited from interface net.sf.hibernate.persister.PropertyMapping
getType, toColumns, toType
 
Methods inherited from interface net.sf.hibernate.persister.Joinable
consumesAlias, getJoinKeyColumnNames, getName, isCollection, isManyToMany, selectFragment
 

Constructor Detail

EntityPersister

public EntityPersister(PersistentClass model,
                       SessionFactoryImplementor factory)
                throws HibernateException
Method Detail

postInstantiate

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

Specified by:
postInstantiate in interface ClassPersister
Throws:
MappingException

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

getDiscriminatorColumnName

public String getDiscriminatorColumnName()
Description copied from interface: OuterJoinLoadable
Get the name of the column used as a discriminator

Specified by:
getDiscriminatorColumnName in interface OuterJoinLoadable

getDiscriminatorAlias

public String getDiscriminatorAlias()
Specified by:
getDiscriminatorAlias in class AbstractEntityPersister

enableJoinedFetch

public int enableJoinedFetch(int i)
Description copied from interface: OuterJoinLoadable
May this property be fetched using an SQL outerjoin.

Specified by:
enableJoinedFetch 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

getTableName

public String getTableName()
Description copied from interface: Joinable
The table to join to.

Specified by:
getTableName in interface Joinable

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

getPropertyColumnNames

public String[] getPropertyColumnNames(int i)
Description copied from class: AbstractEntityPersister
Get the column names for the numbered property of this class

Specified by:
getPropertyColumnNames in class AbstractEntityPersister

getDiscriminatorType

public Type getDiscriminatorType()
Description copied from interface: Loadable
Get the discriminator type

Specified by:
getDiscriminatorType in interface Loadable

getDiscriminatorSQLValue

public Object getDiscriminatorSQLValue()
Description copied from interface: Queryable
Get the discriminator value for this particular concrete subclass, as a string that may be embedded in a select statement

Specified by:
getDiscriminatorSQLValue in interface Queryable

getSubclassClosure

public Class[] getSubclassClosure()

getSubclassForDiscriminatorValue

public Class getSubclassForDiscriminatorValue(Object value)
Description copied from interface: Loadable
Get the concrete subclass corresponding to the given discriminator value

Specified by:
getSubclassForDiscriminatorValue in interface Loadable

getPropertySpaces

public Serializable[] getPropertySpaces()
Description copied from interface: ClassPersister
Returns an array of objects that identify spaces in which properties of this class instance are persisted.

Specified by:
getPropertySpaces in interface ClassPersister

getSQLDeleteString

protected final String getSQLDeleteString()
The query that deletes a row by id (and version)


getSQLInsertString

protected final String getSQLInsertString()
The query that inserts a row with a given id


getSQLIdentityInsertString

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


getSQLUpdateString

protected final String getSQLUpdateString()
The query that updates a row by id (and version)


getVersionSelectString

protected final String getVersionSelectString()
Specified by:
getVersionSelectString in class AbstractEntityPersister

generateDeleteString

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


generateInsertString

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


generateSelectForUpdateString

protected String generateSelectForUpdateString()
Generate the SQL that selects a row by id using FOR UPDATE


generateSelectForUpdateNowaitString

protected String generateSelectForUpdateNowaitString()
Generate the SQL that selects a row by id using FOR UPDATE


generateSelectString

protected String generateSelectString()
Generate the SQL that selects a row by id


generateConcreteSelectString

protected String generateConcreteSelectString(boolean[] includeProperty)
Generate the SQL that selects a row by id, excluding subclasses


generateUpdateString

protected String generateUpdateString(boolean[] includeProperty)
Generate the SQL that updates a row by id (and version)


generateUpdateString

protected String generateUpdateString(boolean[] includeProperty,
                                      Object[] oldFields)

generateLockString

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

Specified by:
generateLockString in class AbstractEntityPersister

dehydrate

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

Throws:
SQLException
HibernateException

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 ClassPersister
Throws:
HibernateException

insert

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

Specified by:
insert in interface ClassPersister
Throws:
HibernateException

insert

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

Specified by:
insert in interface ClassPersister
Throws:
HibernateException

insert

public void insert(Serializable id,
                   Object[] fields,
                   boolean[] notNull,
                   String sql,
                   Object object,
                   SessionImplementor session)
            throws HibernateException
Persist an object

Throws:
HibernateException

insert

public Serializable insert(Object[] fields,
                           boolean[] notNull,
                           String sql,
                           Object object,
                           SessionImplementor session)
                    throws HibernateException
Persist an object, using a natively generated identifier

Throws:
HibernateException

delete

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

Specified by:
delete in interface ClassPersister
Throws:
HibernateException

update

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

Specified by:
update in interface ClassPersister
Throws:
HibernateException

update

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

fromTableFragment

public String fromTableFragment(String name)
Description copied from interface: OuterJoinLoadable
Get the main from table fragment, given a query alias.

Specified by:
fromTableFragment in interface OuterJoinLoadable

queryWhereFragment

public String queryWhereFragment(String name,
                                 boolean innerJoin,
                                 boolean includeSubclasses)
                          throws MappingException
Description copied from interface: Queryable
Get the where clause fragment, given a query alias

Specified by:
queryWhereFragment in interface Queryable
Throws:
MappingException

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

getSubclassPropertyTableName

public String getSubclassPropertyTableName(int i)
Description copied from interface: OuterJoinLoadable
Return the table name used to persist the numbered property of the class or a subclass.

Specified by:
getSubclassPropertyTableName in interface OuterJoinLoadable

propertySelectFragment

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

Specified by:
propertySelectFragment in interface Queryable

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

getActualPropertyColumnNames

protected String[] getActualPropertyColumnNames(int i)
Specified by:
getActualPropertyColumnNames in class AbstractEntityPersister

getFormulaTemplate

protected String getFormulaTemplate(int i)
Specified by:
getFormulaTemplate in class AbstractEntityPersister

getConcreteSelectString

protected String getConcreteSelectString()
Specified by:
getConcreteSelectString in class AbstractEntityPersister

isCacheInvalidationRequired

public boolean isCacheInvalidationRequired()
Description copied from interface: ClassPersister
Should we always invalidate the cache instead of recaching updated state

Specified by:
isCacheInvalidationRequired in interface ClassPersister

getVersionedTableName

protected String getVersionedTableName()
Specified by:
getVersionedTableName in class AbstractEntityPersister