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

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


net.sf.hibernate.persister
Class NormalizedEntityPersister

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

public class NormalizedEntityPersister
extends AbstractEntityPersister

A ClassPersister implementing the normalized "table-per-subclass" mapping strategy.

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
NormalizedEntityPersister(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[] statements, 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 alias)
          Get the main from table fragment, given a query alias.
protected  String generateConcreteSelectString()
           
protected  String[] generateDeleteStrings()
          Generate the SQL that deletes rows by id (and version)
protected  String[] generateInsertStrings(boolean identityInsert, boolean[] includeProperty)
          Generate the SQL that inserts rows
protected  String generateLockString()
          Generate the SQL that pessimistic locks a row by id (and version)
protected  String[] generateUpdateStrings(boolean[] includeProperty)
          Generate the SQL that updates rows by id (and version)
protected  String[] getActualPropertyColumnNames(int i)
           
protected  String getConcreteSelectString()
          Generate the SQL that selects a row by id, excluding subclasses
 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[] getIdentifierColumnNames()
          Get the names of columns used to persist the identifier
 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  int getPropertyTableNumber(String propertyName)
           
protected  String[] getSQLDeleteStrings()
          The queries that delete rows by id (and version)
protected  String[] getSQLIdentityInsertStrings()
          The queries that insert rows, letting the database generate an id
protected  String[] getSQLInsertStrings()
          The queries that insert rows with a given id
protected  String[] getSQLUpdateStrings()
          The queries that update rows by id (and version)
 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()
           
protected  void handlePath(String path, Type type)
           
 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 alias, String suffix)
          Given a query alias and an identifying suffix, render the property select fragment.
 String queryWhereFragment(String alias, boolean innerJoin, boolean includeSubclasses)
          Get the where clause fragment, given a query alias
 String[] toColumns(String alias, int i)
          Given the number of a property of a subclass, and a table alias, return the aliased column names.
 String[] toColumns(String alias, String property)
          Given a query alias and a property path, return the qualified column name
protected  void update(Serializable id, Object[] fields, boolean[] includeProperty, boolean[] includeTable, Object oldVersion, Object object, String[] sql, SessionImplementor session)
           
 void update(Serializable id, Object[] fields, int[] dirtyFields, Object[] oldFields, Object oldVersion, Object object, SessionImplementor session)
          Update an object
 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, 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, initComponentPropertyPaths, initIdentifierPropertyPaths, initPropertyPaths, initPropertyPaths, 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.PropertyMapping
toType
 

Constructor Detail

NormalizedEntityPersister

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

Throws:
MappingException

isDefinedOnSubclass

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


getDiscriminatorColumnName

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


getDiscriminatorAlias

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

getSubclassPropertyType

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


getSubclassPropertyName

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


countSubclassProperties

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


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.


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.


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


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


getSubclassForDiscriminatorValue

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


enableJoinedFetch

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


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.


getSQLDeleteStrings

protected final String[] getSQLDeleteStrings()
The queries that delete rows by id (and version)


getSQLInsertStrings

protected final String[] getSQLInsertStrings()
The queries that insert rows with a given id


getSQLIdentityInsertStrings

protected final String[] getSQLIdentityInsertStrings()
The queries that insert rows, letting the database generate an id


getSQLUpdateStrings

protected final String[] getSQLUpdateStrings()
The queries that update rows by id (and version)


getVersionSelectString

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

generateDeleteStrings

protected String[] generateDeleteStrings()
Generate the SQL that deletes rows by id (and version)


generateInsertStrings

protected String[] generateInsertStrings(boolean identityInsert,
                                         boolean[] includeProperty)
Generate the SQL that inserts rows


generateUpdateStrings

protected String[] generateUpdateStrings(boolean[] includeProperty)
Generate the SQL that updates rows by id (and version)


generateLockString

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

Specified by:
generateLockString in class AbstractEntityPersister

getConcreteSelectString

protected String getConcreteSelectString()
Generate the SQL that selects a row by id, excluding subclasses

Specified by:
getConcreteSelectString in class AbstractEntityPersister

generateConcreteSelectString

protected String generateConcreteSelectString()

dehydrate

protected int dehydrate(Serializable id,
                        Object[] fields,
                        boolean[] includeProperty,
                        PreparedStatement[] statements,
                        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

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)

Throws:
HibernateException

insert

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

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

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

Throws:
HibernateException

update

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

getPropertyTableNumber

protected int getPropertyTableNumber(String propertyName)

handlePath

protected void handlePath(String path,
                          Type type)
Overrides:
handlePath in class AbstractPropertyMapping

fromTableFragment

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


getTableName

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


toColumns

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

Specified by:
toColumns in interface PropertyMapping
Overrides:
toColumns in class AbstractPropertyMapping
Throws:
QueryException

toColumns

public String[] toColumns(String alias,
                          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.


propertySelectFragment

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


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)


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)


queryWhereFragment

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

Throws:
MappingException

getIdentifierColumnNames

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

Specified by:
getIdentifierColumnNames in interface OuterJoinLoadable
Overrides:
getIdentifierColumnNames in class AbstractEntityPersister

getActualPropertyColumnNames

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

getFormulaTemplate

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

isCacheInvalidationRequired

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


getVersionedTableName

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