Package org.hibernate.tuple.entity
Class AbstractEntityTuplizer
- java.lang.Object
-
- org.hibernate.tuple.entity.AbstractEntityTuplizer
-
- All Implemented Interfaces:
EntityTuplizer
,Tuplizer
- Direct Known Subclasses:
DynamicMapEntityTuplizer
,PojoEntityTuplizer
public abstract class AbstractEntityTuplizer extends java.lang.Object implements EntityTuplizer
Support for tuplizers relating to entities.
-
-
Field Summary
Fields Modifier and Type Field Description protected Getter[]
getters
protected boolean
hasCustomAccessors
protected int
propertySpan
protected Setter[]
setters
-
Constructor Summary
Constructors Constructor Description AbstractEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)
Constructs a new AbstractEntityTuplizer instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
afterInitialize(java.lang.Object entity, SharedSessionContractImplementor session)
Called just after the entities properties have been initialized.protected abstract Instantiator
buildInstantiator(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)
Build an appropriate Instantiator for the given mapped entity.protected abstract Getter
buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity)
Build an appropriate Getter for the given property.protected abstract Setter
buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity)
Build an appropriate Setter for the given property.protected abstract ProxyFactory
buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter)
Build an appropriate ProxyFactory for the given mapped entity.java.lang.Object
createProxy(java.io.Serializable id, SharedSessionContractImplementor session)
Generates an appropriate proxy representation of this entity for this entity-mode.protected java.lang.Object
getComponentValue(ComponentType type, java.lang.Object component, java.lang.String propertyPath)
Extract a component property value.protected EntityMetamodel
getEntityMetamodel()
protected java.lang.String
getEntityName()
Retrieves the defined entity-name for the tuplized entity.protected SessionFactoryImplementor
getFactory()
Getter
getGetter(int i)
Retrieve the getter for the specified property.java.io.Serializable
getIdentifier(java.lang.Object entity)
Extract the identifier value from the given entity.java.io.Serializable
getIdentifier(java.lang.Object entity, SharedSessionContractImplementor session)
Extract the identifier value from the given entity.Getter
getIdentifierGetter()
Retrieve the getter for the identifier property.Type
getIdentifierMapperType()
protected Instantiator
getInstantiator()
java.lang.Object
getPropertyValue(java.lang.Object entity, int i)
Extract the value of a particular property from the given entity.java.lang.Object
getPropertyValue(java.lang.Object entity, java.lang.String propertyPath)
Extract the value of a particular property from the given entity.java.lang.Object[]
getPropertyValues(java.lang.Object entity)
Extract the current values contained on the given entity.java.lang.Object[]
getPropertyValuesToInsert(java.lang.Object entity, java.util.Map mergeMap, SharedSessionContractImplementor session)
Extract the values of the insertable properties of the entity (including backrefs)ProxyFactory
getProxyFactory()
protected java.util.Set
getSubclassEntityNames()
Retrieves the defined entity-names for any subclasses defined for this entity.java.lang.Object
getVersion(java.lang.Object entity)
Extract the value of the version property from the given entity.Getter
getVersionGetter()
Retrieve the getter for the version property.boolean
hasProxy()
Does this entity, for this mode, present a possibility for proxying?java.lang.Object
instantiate()
Generate a new, empty entity.java.lang.Object
instantiate(java.io.Serializable id)
Create an entity instance initialized with the given identifier.java.lang.Object
instantiate(java.io.Serializable id, SharedSessionContractImplementor session)
Create an entity instance initialized with the given identifier.boolean
isInstance(java.lang.Object object)
Is the given object considered an instance of the the entity (accounting for entity-mode) managed by this tuplizer.boolean
isLifecycleImplementor()
protected void
linkToSession(java.lang.Object entity, SharedSessionContractImplementor session)
void
resetIdentifier(java.lang.Object entity, java.io.Serializable currentId, java.lang.Object currentVersion)
Inject the given identifier and version into the entity, in order to "roll back" to their original values.void
resetIdentifier(java.lang.Object entity, java.io.Serializable currentId, java.lang.Object currentVersion, SharedSessionContractImplementor session)
Inject the given identifier and version into the entity, in order to "roll back" to their original values.void
setIdentifier(java.lang.Object entity, java.io.Serializable id)
Inject the identifier value into the given entity.void
setIdentifier(java.lang.Object entity, java.io.Serializable id, SharedSessionContractImplementor session)
Inject the identifier value into the given entity.void
setPropertyValue(java.lang.Object entity, int i, java.lang.Object value)
Inject the value of a particular property.void
setPropertyValue(java.lang.Object entity, java.lang.String propertyName, java.lang.Object value)
Inject the value of a particular property.void
setPropertyValues(java.lang.Object entity, java.lang.Object[] values)
Inject the given values into the given entity.protected boolean
shouldGetAllProperties(java.lang.Object entity)
java.lang.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.entity.EntityTuplizer
determineConcreteSubclassEntityName, getConcreteProxyClass, getEntityMode, getEntityNameResolvers
-
Methods inherited from interface org.hibernate.tuple.Tuplizer
getMappedClass
-
-
-
-
Constructor Detail
-
AbstractEntityTuplizer
public AbstractEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)
Constructs a new AbstractEntityTuplizer instance.- Parameters:
entityMetamodel
- The "interpreted" information relating to the mapped entity.mappingInfo
- The parsed "raw" mapping data relating to the given entity.
-
-
Method Detail
-
getIdentifierMapperType
public Type getIdentifierMapperType()
-
buildPropertyGetter
protected abstract Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity)
Build an appropriate Getter for the given property.- Parameters:
mappedProperty
- The property to be accessed via the built Getter.mappedEntity
- The entity information regarding the mapped entity owning this property.- Returns:
- An appropriate Getter instance.
-
buildPropertySetter
protected abstract Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity)
Build an appropriate Setter for the given property.- Parameters:
mappedProperty
- The property to be accessed via the built Setter.mappedEntity
- The entity information regarding the mapped entity owning this property.- Returns:
- An appropriate Setter instance.
-
buildInstantiator
protected abstract Instantiator buildInstantiator(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)
Build an appropriate Instantiator for the given mapped entity.- Parameters:
mappingInfo
- The mapping information regarding the mapped entity.- Returns:
- An appropriate Instantiator instance.
-
buildProxyFactory
protected abstract ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter)
Build an appropriate ProxyFactory for the given mapped entity.- Parameters:
mappingInfo
- The mapping information regarding the mapped entity.idGetter
- The constructed Getter relating to the entity's id property.idSetter
- The constructed Setter relating to the entity's id property.- Returns:
- An appropriate ProxyFactory instance.
-
getEntityName
protected java.lang.String getEntityName()
Retrieves the defined entity-name for the tuplized entity.- Returns:
- The entity-name.
-
getSubclassEntityNames
protected java.util.Set getSubclassEntityNames()
Retrieves the defined entity-names for any subclasses defined for this entity.- Returns:
- Any subclass entity-names.
-
getIdentifier
public java.io.Serializable getIdentifier(java.lang.Object entity) throws HibernateException
Description copied from interface:EntityTuplizer
Extract the identifier value from the given entity.- Specified by:
getIdentifier
in interfaceEntityTuplizer
- 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 occurs accessing its value.
-
getIdentifier
public java.io.Serializable getIdentifier(java.lang.Object entity, SharedSessionContractImplementor session)
Description copied from interface:EntityTuplizer
Extract the identifier value from the given entity.- Specified by:
getIdentifier
in interfaceEntityTuplizer
- Parameters:
entity
- The entity from which to extract the identifier value.session
- The session from which is requests originates- Returns:
- The identifier value.
-
setIdentifier
public void setIdentifier(java.lang.Object entity, java.io.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 interfaceEntityTuplizer
- Parameters:
entity
- The entity to inject with the identifier value.id
- The value to be injected as the identifier.- Throws:
HibernateException
-
setIdentifier
public void setIdentifier(java.lang.Object entity, java.io.Serializable id, SharedSessionContractImplementor session)
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 interfaceEntityTuplizer
- Parameters:
entity
- The entity to inject with the identifier value.id
- The value to be injected as the identifier.session
- The session from which is requests originates
-
resetIdentifier
public void resetIdentifier(java.lang.Object entity, java.io.Serializable currentId, java.lang.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 interfaceEntityTuplizer
- Parameters:
entity
- The entity for which to reset the id/version valuescurrentId
- The identifier value to inject into the entity.currentVersion
- The version value to inject into the entity.
-
resetIdentifier
public void resetIdentifier(java.lang.Object entity, java.io.Serializable currentId, java.lang.Object currentVersion, SharedSessionContractImplementor session)
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 interfaceEntityTuplizer
- Parameters:
entity
- The entity for which to reset the id/version valuescurrentId
- The identifier value to inject into the entity.currentVersion
- The version value to inject into the entity.session
- The session from which the request originated
-
getVersion
public java.lang.Object getVersion(java.lang.Object entity) throws HibernateException
Description copied from interface:EntityTuplizer
Extract the value of the version property from the given entity.- Specified by:
getVersion
in interfaceEntityTuplizer
- 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
- Indicates a problem accessing the version property
-
shouldGetAllProperties
protected boolean shouldGetAllProperties(java.lang.Object entity)
-
getPropertyValues
public java.lang.Object[] getPropertyValues(java.lang.Object entity)
Description copied from interface:Tuplizer
Extract the current values contained on the given entity.- Specified by:
getPropertyValues
in interfaceTuplizer
- Parameters:
entity
- The entity from which to extract values.- Returns:
- The current property values.
-
getPropertyValuesToInsert
public java.lang.Object[] getPropertyValuesToInsert(java.lang.Object entity, java.util.Map mergeMap, SharedSessionContractImplementor session)
Description copied from interface:EntityTuplizer
Extract the values of the insertable properties of the entity (including backrefs)- Specified by:
getPropertyValuesToInsert
in interfaceEntityTuplizer
- Parameters:
entity
- The entity from which to extract.mergeMap
- a map of instances being merged to merged instancessession
- The session in which the result set is being made.- Returns:
- The insertable property values.
-
getPropertyValue
public java.lang.Object getPropertyValue(java.lang.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 interfaceTuplizer
- 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 java.lang.Object getPropertyValue(java.lang.Object entity, java.lang.String propertyPath) throws HibernateException
Description copied from interface:EntityTuplizer
Extract the value of a particular property from the given entity.- Specified by:
getPropertyValue
in interfaceEntityTuplizer
- Parameters:
entity
- The entity from which to extract the property value.propertyPath
- 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
- Indicates a problem access the property
-
getComponentValue
protected java.lang.Object getComponentValue(ComponentType type, java.lang.Object component, java.lang.String propertyPath)
Extract a component property value.- Parameters:
type
- The component property types.component
- The component instance itself.propertyPath
- The property path for the property to be extracted.- Returns:
- The property value extracted.
-
setPropertyValues
public void setPropertyValues(java.lang.Object entity, java.lang.Object[] values) throws HibernateException
Description copied from interface:Tuplizer
Inject the given values into the given entity.- Specified by:
setPropertyValues
in interfaceTuplizer
- Parameters:
entity
- The entity.values
- The values to be injected.- Throws:
HibernateException
-
setPropertyValue
public void setPropertyValue(java.lang.Object entity, int i, java.lang.Object value) throws HibernateException
Description copied from interface:EntityTuplizer
Inject the value of a particular property.- Specified by:
setPropertyValue
in interfaceEntityTuplizer
- Parameters:
entity
- The entity into which to inject the value.i
- The property's index.value
- The property value to inject.- Throws:
HibernateException
- Indicates a problem access the property
-
setPropertyValue
public void setPropertyValue(java.lang.Object entity, java.lang.String propertyName, java.lang.Object value) throws HibernateException
Description copied from interface:EntityTuplizer
Inject the value of a particular property.- Specified by:
setPropertyValue
in interfaceEntityTuplizer
- Parameters:
entity
- The entity into which to inject the value.propertyName
- The name of the property.value
- The property value to inject.- Throws:
HibernateException
- Indicates a problem access the property
-
instantiate
public final java.lang.Object instantiate(java.io.Serializable id) throws HibernateException
Description copied from interface:EntityTuplizer
Create an entity instance initialized with the given identifier.- Specified by:
instantiate
in interfaceEntityTuplizer
- Parameters:
id
- The identifier value for the entity to be instantiated.- Returns:
- The instantiated entity.
- Throws:
HibernateException
-
instantiate
public final java.lang.Object instantiate(java.io.Serializable id, SharedSessionContractImplementor session)
Description copied from interface:EntityTuplizer
Create an entity instance initialized with the given identifier.- Specified by:
instantiate
in interfaceEntityTuplizer
- Parameters:
id
- The identifier value for the entity to be instantiated.session
- The session from which is requests originates- Returns:
- The instantiated entity.
-
linkToSession
protected void linkToSession(java.lang.Object entity, SharedSessionContractImplementor session)
-
instantiate
public final java.lang.Object instantiate() throws HibernateException
Description copied from interface:Tuplizer
Generate a new, empty entity.- Specified by:
instantiate
in interfaceTuplizer
- Returns:
- The new, empty entity instance.
- Throws:
HibernateException
-
afterInitialize
public void afterInitialize(java.lang.Object entity, SharedSessionContractImplementor session)
Description copied from interface:EntityTuplizer
Called just after the entities properties have been initialized.- Specified by:
afterInitialize
in interfaceEntityTuplizer
- Parameters:
entity
- The entity being initialized.session
- The session initializing this entity.
-
isInstance
public final boolean isInstance(java.lang.Object object)
Description copied from interface:Tuplizer
Is the given object considered an instance of the the entity (accounting for entity-mode) managed by this tuplizer.- Specified by:
isInstance
in interfaceTuplizer
- 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 interfaceEntityTuplizer
- Returns:
- True if this tuplizer can generate proxies for this entity.
-
createProxy
public final java.lang.Object createProxy(java.io.Serializable id, SharedSessionContractImplementor session)
Description copied from interface:EntityTuplizer
Generates an appropriate proxy representation of this entity for this entity-mode.- Specified by:
createProxy
in interfaceEntityTuplizer
- 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.
-
isLifecycleImplementor
public boolean isLifecycleImplementor()
Description copied from interface:EntityTuplizer
- Specified by:
isLifecycleImplementor
in interfaceEntityTuplizer
- Returns:
- True if the Lifecycle interface is implemented; false otherwise.
-
getEntityMetamodel
protected final EntityMetamodel getEntityMetamodel()
-
getFactory
protected final SessionFactoryImplementor getFactory()
-
getInstantiator
protected final Instantiator getInstantiator()
-
getProxyFactory
public final ProxyFactory getProxyFactory()
- Specified by:
getProxyFactory
in interfaceEntityTuplizer
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getIdentifierGetter
public Getter getIdentifierGetter()
Description copied from interface:EntityTuplizer
Retrieve the getter for the identifier property. May return null.- Specified by:
getIdentifierGetter
in interfaceEntityTuplizer
- Returns:
- The getter for the identifier property.
-
getVersionGetter
public Getter getVersionGetter()
Description copied from interface:EntityTuplizer
Retrieve the getter for the version property. May return null.- Specified by:
getVersionGetter
in interfaceEntityTuplizer
- Returns:
- The getter for the version property.
-
-