org.hibernate.tuple
Class AbstractTuplizer

java.lang.Object
  extended byorg.hibernate.tuple.AbstractTuplizer
All Implemented Interfaces:
EntityTuplizer, Tuplizer
Direct Known Subclasses:
Dom4jTuplizer, DynamicMapTuplizer, PojoTuplizer

public abstract class AbstractTuplizer
extends Object
implements EntityTuplizer

Support base class for EntityTuplizer implementations.

Author:
Steve Ebersole

Field Summary
protected  Getter[] getters
           
protected  boolean hasCustomAccessors
           
protected  int propertySpan
           
protected  Setter[] setters
           
 
Constructor Summary
AbstractTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity)
           
 
Method Summary
 void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session)
          Called just after the entities properties have been initialized.
protected abstract  Instantiator buildInstantiator(PersistentClass mappingInfo)
           
protected abstract  Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity)
           
protected abstract  Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity)
           
protected abstract  ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter)
           
 Object createProxy(Serializable id, SessionImplementor session)
          Generates an appropriate proxy representation of this entity for this entity-mode.
protected  EntityMetamodel getEntityMetamodel()
           
protected abstract  EntityMode getEntityMode()
           
 String getEntityName()
           
protected  SessionFactoryImplementor getFactory()
           
 Serializable getIdentifier(Object entity)
          Extract the identifier value from the given entity.
protected  Instantiator getInstantiator()
           
 Object getPropertyValue(Object entity, int i)
          Extract the value of a particular property from the given entity.
 Object getPropertyValue(Object entity, String propertyName)
          Extract the value of a particular property from the given entity.
 Object[] getPropertyValues(Object entity)
          Extract the current values contained on the given entity.
 Object[] getPropertyValuesToInsert(Object entity, SessionImplementor session)
          Extract the values of the insertable properties of the entity (including backrefs)
protected  ProxyFactory getProxyFactory()
           
 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()
           
 Object instantiate(Serializable id)
          Create an entity instance initialized with the given identifier.
 boolean isInstance(Object object)
          Is the given object considered an instance of the the entity (acconting for entity-mode) managed by this tuplizer.
 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.
 void setPropertyValues(Object entity, Object[] values)
          Inject the given values into the given entity.
protected  boolean shouldGetAllProperties(Object entity)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.hibernate.tuple.EntityTuplizer
getConcreteProxyClass, isLazyPropertyLoadingAvailable
 
Methods inherited from interface org.hibernate.tuple.Tuplizer
getMappedClass
 

Field Detail

getters

protected final Getter[] getters

setters

protected final Setter[] setters

propertySpan

protected final int propertySpan

hasCustomAccessors

protected final boolean hasCustomAccessors
Constructor Detail

AbstractTuplizer

public AbstractTuplizer(EntityMetamodel entityMetamodel,
                        PersistentClass mappedEntity)
Method Detail

getEntityMode

protected abstract EntityMode getEntityMode()

buildPropertyGetter

protected abstract Getter buildPropertyGetter(Property mappedProperty,
                                              PersistentClass mappedEntity)

buildPropertySetter

protected abstract Setter buildPropertySetter(Property mappedProperty,
                                              PersistentClass mappedEntity)

buildInstantiator

protected abstract Instantiator buildInstantiator(PersistentClass mappingInfo)

buildProxyFactory

protected abstract ProxyFactory buildProxyFactory(PersistentClass mappingInfo,
                                                  Getter idGetter,
                                                  Setter idSetter)

getEntityName

public String getEntityName()

getIdentifier

public Serializable getIdentifier(Object entity)
                           throws HibernateException
Description copied from interface: EntityTuplizer
Extract the identifier value from the given entity.

Specified by:
getIdentifier in interface EntityTuplizer
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
Description copied from interface: EntityTuplizer
Inject the identifier value into the given entity.

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

Specified by:
setIdentifier in interface EntityTuplizer
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)
Description copied from interface: EntityTuplizer
Inject the given identifier and version into the entity, in order to "roll back" to their original values.

Specified by:
resetIdentifier in interface EntityTuplizer
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
Description copied from interface: EntityTuplizer
Extract the value of the version property from the given entity.

Specified by:
getVersion in interface EntityTuplizer
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

shouldGetAllProperties

protected boolean shouldGetAllProperties(Object entity)

getPropertyValues

public Object[] getPropertyValues(Object entity)
                           throws HibernateException
Description copied from interface: Tuplizer
Extract the current values contained on the given entity.

Specified by:
getPropertyValues in interface Tuplizer
Parameters:
entity - The entity from which to extract values.
Returns:
The current property values.
Throws:
HibernateException

getPropertyValuesToInsert

public Object[] getPropertyValuesToInsert(Object entity,
                                          SessionImplementor session)
                                   throws HibernateException
Description copied from interface: EntityTuplizer
Extract the values of the insertable properties of the entity (including backrefs)

Specified by:
getPropertyValuesToInsert in interface EntityTuplizer
Parameters:
entity - The entity from which to extract.
session - The session in which the resuest is being made.
Returns:
The insertable property values.
Throws:
HibernateException

getPropertyValue

public Object getPropertyValue(Object entity,
                               int i)
                        throws HibernateException
Description copied from interface: Tuplizer
Extract the value of a particular property from the given entity.

Specified by:
getPropertyValue in interface Tuplizer
Parameters:
entity - The entity from which to extract the property value.
i - The index of the property for which to extract the value.
Returns:
The current value of the given property on the given entity.
Throws:
HibernateException

getPropertyValue

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

Specified by:
getPropertyValue in interface EntityTuplizer
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

setPropertyValues

public void setPropertyValues(Object entity,
                              Object[] values)
                       throws HibernateException
Description copied from interface: Tuplizer
Inject the given values into the given entity.

Specified by:
setPropertyValues in interface Tuplizer
Parameters:
entity - The entity.
values - The values to be injected.
Throws:
HibernateException

setPropertyValue

public void setPropertyValue(Object entity,
                             int i,
                             Object value)
                      throws HibernateException
Description copied from interface: EntityTuplizer
Inject the value of a particular property.

Specified by:
setPropertyValue in interface EntityTuplizer
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
Description copied from interface: EntityTuplizer
Inject the value of a particular property.

Specified by:
setPropertyValue in interface EntityTuplizer
Parameters:
entity - The entity into which to inject the value.
propertyName - The name of the property.
value - The property value to inject.
Throws:
HibernateException

instantiate

public final Object instantiate(Serializable id)
                         throws HibernateException
Description copied from interface: EntityTuplizer
Create an entity instance initialized with the given identifier.

Specified by:
instantiate in interface EntityTuplizer
Parameters:
id - The identifier value for the entity to be instantiated.
Returns:
The instantiated entity.
Throws:
HibernateException

instantiate

public final Object instantiate()
                         throws HibernateException
Specified by:
instantiate in interface Tuplizer
Throws:
HibernateException

afterInitialize

public void afterInitialize(Object entity,
                            boolean lazyPropertiesAreUnfetched,
                            SessionImplementor session)
Description copied from interface: EntityTuplizer
Called just after the entities properties have been initialized.

Specified by:
afterInitialize in interface EntityTuplizer
Parameters:
entity - The entity being initialized.
lazyPropertiesAreUnfetched - Are defined lazy properties currently unfecthed
session - The session initializing this entity.

hasUninitializedLazyProperties

public boolean hasUninitializedLazyProperties(Object entity)
Description copied from interface: EntityTuplizer
Does the given entity instance have any currently uninitialized lazy properties?

Specified by:
hasUninitializedLazyProperties in interface EntityTuplizer
Parameters:
entity - The entity to be check for uninitialized lazy properties.
Returns:
True if uninitialized lazy properties were found; false otherwise.

isInstance

public final boolean isInstance(Object object)
Description copied from interface: Tuplizer
Is the given object considered an instance of the the entity (acconting for entity-mode) managed by this tuplizer.

Specified by:
isInstance in interface Tuplizer
Parameters:
object - The object to be checked.
Returns:
True if the object is considered as an instance of this entity within the given mode.

hasProxy

public boolean hasProxy()
Description copied from interface: EntityTuplizer
Does this entity, for this mode, present a possibility for proxying?

Specified by:
hasProxy in interface EntityTuplizer
Returns:
True if this tuplizer can generate proxies for this entity.

createProxy

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

Specified by:
createProxy in interface EntityTuplizer
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()
Description copied from interface: EntityTuplizer
Does the class managed by this tuplizer implement the Lifecycle interface.

Specified by:
isLifecycleImplementor in interface EntityTuplizer
Returns:
True if the Lifecycle interface is implemented; false otherwise.

isValidatableImplementor

public boolean isValidatableImplementor()
Description copied from interface: EntityTuplizer
Does the class managed by this tuplizer implement the Validatable interface.

Specified by:
isValidatableImplementor in interface EntityTuplizer
Returns:
True if the Validatable interface is implemented; false otherwise.

getEntityMetamodel

protected final EntityMetamodel getEntityMetamodel()

getFactory

protected final SessionFactoryImplementor getFactory()

getInstantiator

protected final Instantiator getInstantiator()

getProxyFactory

protected final ProxyFactory getProxyFactory()

toString

public String toString()