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

EntityTuplizer (Hibernate API Documentation) - Hibernate 3.2.3 正式版 API 英文文档


org.hibernate.tuple.entity
Interface EntityTuplizer

All Superinterfaces:
Tuplizer
All Known Implementing Classes:
AbstractEntityTuplizer

public interface EntityTuplizer
extends Tuplizer

Defines further responsibilities reagarding tuplization based on a mapped entity.

EntityTuplizer implementations should have the following constructor signature: (org.hibernate.tuple.entity.EntityMetamodel, org.hibernate.mapping.PersistentClass)

Author:
Gavin King, Steve Ebersole

Method Summary
 void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session)
          Called just after the entities properties have been initialized.
 Object createProxy(Serializable id, SessionImplementor session)
          Generates an appropriate proxy representation of this entity for this entity-mode.
 Class getConcreteProxyClass()
          Returns the java class to which generated proxies will be typed.
 Serializable getIdentifier(Object entity)
          Extract the identifier value from the given entity.
 Object getPropertyValue(Object entity, String propertyName)
          Extract the value of a particular property from the given entity.
 Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session)
          Extract the values of the insertable properties of the entity (including backrefs)
 Object getVersion(Object entity)
          Extract the value of the version property from the given entity.
 boolean hasProxy()
          Does this entity, for this mode, present a possibility for proxying?
 boolean hasUninitializedLazyProperties(Object entity)
          Does the given entity instance have any currently uninitialized lazy properties?
 Object instantiate(Serializable id)
          Create an entity instance initialized with the given identifier.
 boolean isInstrumented()
          Is it an instrumented POJO?
 boolean isLifecycleImplementor()
          Does the class managed by this tuplizer implement the Lifecycle interface.
 boolean isValidatableImplementor()
          Does the class managed by this tuplizer implement the Validatable interface.
 void resetIdentifier(Object entity, Serializable currentId, Object currentVersion)
          Inject the given identifier and version into the entity, in order to "roll back" to their original values.
 void setIdentifier(Object entity, Serializable id)
          Inject the identifier value into the given entity.
 void setPropertyValue(Object entity, int i, Object value)
          Inject the value of a particular property.
 void setPropertyValue(Object entity, String propertyName, Object value)
          Inject the value of a particular property.
 
Methods inherited from interface org.hibernate.tuple.Tuplizer
getMappedClass, getPropertyValue, getPropertyValues, instantiate, isInstance, setPropertyValues
 

Method Detail

instantiate

public Object instantiate(Serializable id)
                   throws HibernateException
Create an entity instance initialized with the given identifier.

Parameters:
id - The identifier value for the entity to be instantiated.
Returns:
The instantiated entity.
Throws:
HibernateException

getIdentifier

public Serializable getIdentifier(Object entity)
                           throws HibernateException
Extract the identifier value from the given entity.

Parameters:
entity - The entity from which to extract the identifier value.
Returns:
The identifier value.
Throws:
HibernateException - If the entity does not define an identifier property, or an error occurrs accessing its value.

setIdentifier

public void setIdentifier(Object entity,
                          Serializable id)
                   throws HibernateException
Inject the identifier value into the given entity.

Has no effect if the entity does not define an identifier property

Parameters:
entity - The entity to inject with the identifier value.
id - The value to be injected as the identifier.
Throws:
HibernateException

resetIdentifier

public void resetIdentifier(Object entity,
                            Serializable currentId,
                            Object currentVersion)
Inject the given identifier and version into the entity, in order to "roll back" to their original values.

Parameters:
currentId - The identifier value to inject into the entity.
currentVersion - The version value to inject into the entity.

getVersion

public Object getVersion(Object entity)
                  throws HibernateException
Extract the value of the version property from the given entity.

Parameters:
entity - The entity from which to extract the version value.
Returns:
The value of the version property, or null if not versioned.
Throws:
HibernateException

setPropertyValue

public void setPropertyValue(Object entity,
                             int i,
                             Object value)
                      throws HibernateException
Inject the value of a particular property.

Parameters:
entity - The entity into which to inject the value.
i - The property's index.
value - The property value to inject.
Throws:
HibernateException

setPropertyValue

public void setPropertyValue(Object entity,
                             String propertyName,
                             Object value)
                      throws HibernateException
Inject the value of a particular property.

Parameters:
entity - The entity into which to inject the value.
propertyName - The name of the property.
value - The property value to inject.
Throws:
HibernateException

getPropertyValuesToInsert

public Object[] getPropertyValuesToInsert(Object entity,
                                          Map mergeMap,
                                          SessionImplementor session)
                                   throws HibernateException
Extract the values of the insertable properties of the entity (including backrefs)

Parameters:
entity - The entity from which to extract.
mergeMap - a map of instances being merged to merged instances
session - The session in which the resuest is being made.
Returns:
The insertable property values.
Throws:
HibernateException

getPropertyValue

public Object getPropertyValue(Object entity,
                               String propertyName)
                        throws HibernateException
Extract the value of a particular property from the given entity.

Parameters:
entity - The entity from which to extract the property value.
propertyName - The name of the property for which to extract the value.
Returns:
The current value of the given property on the given entity.
Throws:
HibernateException

afterInitialize

public void afterInitialize(Object entity,
                            boolean lazyPropertiesAreUnfetched,
                            SessionImplementor session)
Called just after the entities properties have been initialized.

Parameters:
entity - The entity being initialized.
lazyPropertiesAreUnfetched - Are defined lazy properties currently unfecthed
session - The session initializing this entity.

hasProxy

public boolean hasProxy()
Does this entity, for this mode, present a possibility for proxying?

Returns:
True if this tuplizer can generate proxies for this entity.

createProxy

public Object createProxy(Serializable id,
                          SessionImplementor session)
                   throws HibernateException
Generates an appropriate proxy representation of this entity for this entity-mode.

Parameters:
id - The id of the instance for which to generate a proxy.
session - The session to which the proxy should be bound.
Returns:
The generate proxies.
Throws:
HibernateException - Indicates an error generating the proxy.

isLifecycleImplementor

public boolean isLifecycleImplementor()
Does the class managed by this tuplizer implement the Lifecycle interface.

Returns:
True if the Lifecycle interface is implemented; false otherwise.

isValidatableImplementor

public boolean isValidatableImplementor()
Does the class managed by this tuplizer implement the Validatable interface.

Returns:
True if the Validatable interface is implemented; false otherwise.

getConcreteProxyClass

public Class getConcreteProxyClass()
Returns the java class to which generated proxies will be typed.

Returns:
The java class to which generated proxies will be typed

hasUninitializedLazyProperties

public boolean hasUninitializedLazyProperties(Object entity)
Does the given entity instance have any currently uninitialized lazy properties?

Parameters:
entity - The entity to be check for uninitialized lazy properties.
Returns:
True if uninitialized lazy properties were found; false otherwise.

isInstrumented

public boolean isInstrumented()
Is it an instrumented POJO?