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

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


net.sf.hibernate.persister
Interface ClassPersister

All Known Subinterfaces:
Loadable, OuterJoinLoadable, Queryable, SQLLoadable, UniqueKeyLoadable
All Known Implementing Classes:
AbstractEntityPersister, EntityPersister

public interface ClassPersister

Concrete ClassPersisters implement mapping and persistence logic for a particular persistent class.

Implementors must be threadsafe (preferrably immutable) and must provide a constructor of type (net.sf.hibernate.map.PersistentClass, net.sf.hibernate.impl.SessionFactoryImplementor).

Author:
Gavin King
See Also:
EntityPersister

Field Summary
static String ENTITY_ID
          The property name of the "special" identifier property in HQL
 
Method Summary
 Object createProxy(Serializable id, SessionImplementor session)
          Create a new proxy instance
 void delete(Serializable id, Object version, Object object, SessionImplementor session)
          Delete a persistent instance
 int[] findDirty(Object[] x, Object[] y, Object owner, SessionImplementor session)
          Compare two snapshots of the state of an instance to determine if the persistent state was modified
 int[] findModified(Object[] old, Object[] current, Object object, SessionImplementor session)
          Compare the state of an instance to the current database state
 CacheConcurrencyStrategy getCache()
          Get the cache (optional operation)
 ClassMetadata getClassMetadata()
          Get the user-visible metadata for the class (optional operation)
 String getClassName()
          The classname of the persistent class (used only for messages)
 Class getConcreteProxyClass()
          Get the proxy interface that instances of this concrete class will be cast to (optional operation).
 Object[] getCurrentPersistentState(Serializable id, Object version, SessionImplementor session)
          Get the current database state of the object, in a "hydrated" form, without resolving identifiers
 Object getCurrentVersion(Serializable id, SessionImplementor session)
          Get the current version of the object, or return null if there is no row for the given identifier.
 Serializable getIdentifier(Object object)
          Get the identifier of an instance (throw an exception if no identifier property)
 IdentifierGenerator getIdentifierGenerator()
          Return the IdentifierGenerator for the class
 String getIdentifierPropertyName()
          Get the name of the identifier property (or return null) - need not return the name of an actual Java property
 Serializable getIdentifierSpace()
          Returns an object that identifies the space in which identifiers of this class hierarchy are unique.
 Type getIdentifierType()
          Get the identifier type
 Class getMappedClass()
          The persistent class
 Cascades.CascadeStyle[] getPropertyCascadeStyles()
          Get the cascade styles of the propertes (optional operation)
 boolean[] getPropertyInsertability()
          Get the "insertability" of the properties of this class (does the property appear in an SQL INSERT)
 String[] getPropertyNames()
          Get the names of the class properties - doesn't have to be the names of the actual Java properties (used for XML generation only)
 boolean[] getPropertyNullability()
          Get the nullability of the properties of this class
 Serializable[] getPropertySpaces()
          Returns an array of objects that identify spaces in which properties of this class instance are persisted.
 Type getPropertyType(String propertyName)
          Get the type of a particular property
 Type[] getPropertyTypes()
          Get the Hibernate types of the class properties
 boolean[] getPropertyUpdateability()
          Get the "updateability" of the properties of this class (does the property appear in an SQL UPDATE)
 Object getPropertyValue(Object object, int i)
          Get the value of a particular property
 Object getPropertyValue(Object object, String propertyName)
          Get the value of a particular property
 Object[] getPropertyValues(Object object)
          Return the values of the mapped properties of the object
 Object getVersion(Object object)
          Get the version number (or timestamp) from the object's version property (or return null if not versioned)
 int getVersionProperty()
          Which property holds the version number (optional operation).
 VersionType getVersionType()
          Get the type of versioning (optional operation)
 boolean hasCache()
          Does this class have a cache.
 boolean hasCascades()
          Does this class declare any cascading save/update/deletes.
 boolean hasCollections()
          Do instances of this class contain collections.
 boolean hasIdentifierProperty()
          Does the class have a property holding the identifier value?
 boolean hasIdentifierPropertyOrEmbeddedCompositeIdentifier()
          Do detached instances of this class carry their own identifier value?
 boolean hasProxy()
          Does this class support dynamic proxies.
 boolean implementsLifecycle()
          Does the class implement the Lifecycle interface.
 boolean implementsValidatable()
          Does the class implement the Validatable interface.
 Serializable insert(Object[] fields, Object object, SessionImplementor session)
          Persist an instance, using a natively generated identifier (optional operation)
 void insert(Serializable id, Object[] fields, Object object, SessionImplementor session)
          Persist an instance
 Object instantiate(Serializable id)
          Create a class instance initialized with the given identifier
 boolean isBatchLoadable()
          Is batch loading enabled?
 boolean isCacheInvalidationRequired()
          Should we always invalidate the cache instead of recaching updated state
 boolean isIdentifierAssignedByInsert()
          Is the identifier assigned before the insert by an IDGenerator.
 boolean isMutable()
          Are instances of this class mutable.
 boolean isUnsaved(Object object)
          Is this a new transient instance?
 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 of the persistent class.
 void lock(Serializable id, Object version, Object object, LockMode lockMode, SessionImplementor session)
          Do a version check (optional operation)
 void postInstantiate()
          Finish the initialization of this object, once all ClassPersisters have been instantiated.
 void setIdentifier(Object object, Serializable id)
          Set the identifier of an instance (or do nothing if no identifier property)
 void setPropertyValue(Object object, int i, Object value)
          Set the value of a particular property
 void setPropertyValues(Object object, Object[] values)
          Set the given values to the mapped properties of the given object
 void update(Serializable id, Object[] fields, int[] dirtyFields, Object[] oldFields, Object oldVersion, Object object, SessionImplementor session)
          Update a persistent instance
 

Field Detail

ENTITY_ID

public static final String ENTITY_ID
The property name of the "special" identifier property in HQL

See Also:
Constant Field Values
Method Detail

postInstantiate

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

Throws:
MappingException

getIdentifierSpace

public Serializable getIdentifierSpace()
Returns an object that identifies the space in which identifiers of this class hierarchy are unique. A table name, a JNDI URL, etc.


getPropertySpaces

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


getMappedClass

public Class getMappedClass()
The persistent class


getClassName

public String getClassName()
The classname of the persistent class (used only for messages)


implementsLifecycle

public boolean implementsLifecycle()
Does the class implement the Lifecycle interface.


implementsValidatable

public boolean implementsValidatable()
Does the class implement the Validatable interface.


hasProxy

public boolean hasProxy()
Does this class support dynamic proxies.


getConcreteProxyClass

public Class getConcreteProxyClass()
Get the proxy interface that instances of this concrete class will be cast to (optional operation).


createProxy

public Object createProxy(Serializable id,
                          SessionImplementor session)
                   throws HibernateException
Create a new proxy instance

Throws:
HibernateException

hasCollections

public boolean hasCollections()
Do instances of this class contain collections.


hasCascades

public boolean hasCascades()
Does this class declare any cascading save/update/deletes.


isMutable

public boolean isMutable()
Are instances of this class mutable.


isIdentifierAssignedByInsert

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


isUnsaved

public boolean isUnsaved(Object object)
                  throws HibernateException
Is this a new transient instance?

Throws:
HibernateException

setPropertyValues

public void setPropertyValues(Object object,
                              Object[] values)
                       throws HibernateException
Set the given values to the mapped properties of the given object

Throws:
HibernateException

getPropertyValues

public Object[] getPropertyValues(Object object)
                           throws HibernateException
Return the values of the mapped properties of the object

Throws:
HibernateException

setPropertyValue

public void setPropertyValue(Object object,
                             int i,
                             Object value)
                      throws HibernateException
Set the value of a particular property

Throws:
HibernateException

getPropertyValue

public Object getPropertyValue(Object object,
                               int i)
                        throws HibernateException
Get the value of a particular property

Throws:
HibernateException

getPropertyValue

public Object getPropertyValue(Object object,
                               String propertyName)
                        throws HibernateException
Get the value of a particular property

Throws:
HibernateException

getPropertyType

public Type getPropertyType(String propertyName)
                     throws MappingException
Get the type of a particular property

Throws:
MappingException

findDirty

public int[] findDirty(Object[] x,
                       Object[] y,
                       Object owner,
                       SessionImplementor session)
                throws HibernateException
Compare two snapshots of the state of an instance to determine if the persistent state was modified

Returns:
null or the indices of the dirty properties
Throws:
HibernateException

findModified

public int[] findModified(Object[] old,
                          Object[] current,
                          Object object,
                          SessionImplementor session)
                   throws HibernateException
Compare the state of an instance to the current database state

Returns:
null or the indices of the dirty properties
Throws:
HibernateException

hasIdentifierProperty

public boolean hasIdentifierProperty()
Does the class have a property holding the identifier value?


hasIdentifierPropertyOrEmbeddedCompositeIdentifier

public boolean hasIdentifierPropertyOrEmbeddedCompositeIdentifier()
Do detached instances of this class carry their own identifier value?


getIdentifier

public Serializable getIdentifier(Object object)
                           throws HibernateException
Get the identifier of an instance (throw an exception if no identifier property)

Throws:
HibernateException

setIdentifier

public void setIdentifier(Object object,
                          Serializable id)
                   throws HibernateException
Set the identifier of an instance (or do nothing if no identifier property)

Throws:
HibernateException

isVersioned

public boolean isVersioned()
Are instances of this class versioned by a timestamp or version number column.


getVersionType

public VersionType getVersionType()
Get the type of versioning (optional operation)


getVersionProperty

public int getVersionProperty()
Which property holds the version number (optional operation).


getVersion

public Object getVersion(Object object)
                  throws HibernateException
Get the version number (or timestamp) from the object's version property (or return null if not versioned)

Throws:
HibernateException

instantiate

public Object instantiate(Serializable id)
                   throws HibernateException
Create a class instance initialized with the given identifier

Throws:
HibernateException

getIdentifierGenerator

public IdentifierGenerator getIdentifierGenerator()
                                           throws HibernateException
Return the IdentifierGenerator for the class

Throws:
HibernateException

load

public Object load(Serializable id,
                   Object optionalObject,
                   LockMode lockMode,
                   SessionImplementor session)
            throws HibernateException
Load an instance of the persistent class.

Throws:
HibernateException

lock

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

Throws:
HibernateException

insert

public void insert(Serializable id,
                   Object[] fields,
                   Object object,
                   SessionImplementor session)
            throws HibernateException
Persist an instance

Throws:
HibernateException

insert

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

Throws:
HibernateException

delete

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

Throws:
HibernateException

update

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

Throws:
HibernateException

getPropertyTypes

public Type[] getPropertyTypes()
Get the Hibernate types of the class properties


getPropertyNames

public String[] getPropertyNames()
Get the names of the class properties - doesn't have to be the names of the actual Java properties (used for XML generation only)


getPropertyUpdateability

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


getPropertyNullability

public boolean[] getPropertyNullability()
Get the nullability of the properties of this class


getPropertyInsertability

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


getPropertyCascadeStyles

public Cascades.CascadeStyle[] getPropertyCascadeStyles()
Get the cascade styles of the propertes (optional operation)


getIdentifierType

public Type getIdentifierType()
Get the identifier type


getIdentifierPropertyName

public String getIdentifierPropertyName()
Get the name of the identifier property (or return null) - need not return the name of an actual Java property


isCacheInvalidationRequired

public boolean isCacheInvalidationRequired()
Should we always invalidate the cache instead of recaching updated state


hasCache

public boolean hasCache()
Does this class have a cache.


getCache

public CacheConcurrencyStrategy getCache()
Get the cache (optional operation)


getClassMetadata

public ClassMetadata getClassMetadata()
Get the user-visible metadata for the class (optional operation)


isBatchLoadable

public boolean isBatchLoadable()
Is batch loading enabled?


getCurrentPersistentState

public Object[] getCurrentPersistentState(Serializable id,
                                          Object version,
                                          SessionImplementor session)
                                   throws HibernateException
Get the current database state of the object, in a "hydrated" form, without resolving identifiers

Returns:
null if select-before-update is not enabled or not supported
Throws:
HibernateException

getCurrentVersion

public Object getCurrentVersion(Serializable id,
                                SessionImplementor session)
                         throws HibernateException
Get the current version of the object, or return null if there is no row for the given identifier. In the case of unversioned data, return any object if the row exists.

Throws:
HibernateException