Package org.hibernate.tuple.entity
Interface EntityTuplizer
-
- All Superinterfaces:
Tuplizer
- All Known Implementing Classes:
AbstractEntityTuplizer
,DynamicMapEntityTuplizer
,PojoEntityTuplizer
public interface EntityTuplizer extends Tuplizer
Defines further responsibilities reagarding tuplization based on a mapped entity. EntityTuplizer implementations should have the following constructor signatures: (org.hibernate.tuple.entity.EntityMetamodel, org.hibernate.mapping.PersistentClass) (org.hibernate.tuple.entity.EntityMetamodel, org.hibernate.metamodel.binding.EntityBinding)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
afterInitialize(java.lang.Object entity, SharedSessionContractImplementor session)
Called just after the entities properties have been initialized.java.lang.Object
createProxy(java.io.Serializable id, SharedSessionContractImplementor session)
Generates an appropriate proxy representation of this entity for this entity-mode.java.lang.String
determineConcreteSubclassEntityName(java.lang.Object entityInstance, SessionFactoryImplementor factory)
Given an entity instance, determine the most appropriate (most targeted) entity-name which represents it.java.lang.Class
getConcreteProxyClass()
Returns the java class to which generated proxies will be typed.EntityMode
getEntityMode()
Return the entity-mode handled by this tuplizer instance.EntityNameResolver[]
getEntityNameResolvers()
Get anyEntityNameResolvers
associated with thisTuplizer
.java.io.Serializable
getIdentifier(java.lang.Object entity)
Deprecated.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.java.lang.Object
getPropertyValue(java.lang.Object entity, java.lang.String propertyName)
Extract the value of a particular property from 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)default ProxyFactory
getProxyFactory()
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(java.io.Serializable id)
Deprecated.java.lang.Object
instantiate(java.io.Serializable id, SharedSessionContractImplementor session)
Create an entity instance initialized with the given identifier.boolean
isLifecycleImplementor()
void
resetIdentifier(java.lang.Object entity, java.io.Serializable currentId, java.lang.Object currentVersion)
Deprecated.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)
Deprecated.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.-
Methods inherited from interface org.hibernate.tuple.Tuplizer
getGetter, getMappedClass, getPropertyValue, getPropertyValues, instantiate, isInstance, setPropertyValues
-
-
-
-
Method Detail
-
getEntityMode
EntityMode getEntityMode()
Return the entity-mode handled by this tuplizer instance.- Returns:
- The entity-mode
-
instantiate
@Deprecated java.lang.Object instantiate(java.io.Serializable id) throws HibernateException
Deprecated.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
-
instantiate
java.lang.Object instantiate(java.io.Serializable id, SharedSessionContractImplementor session)
Create an entity instance initialized with the given identifier.- Parameters:
id
- The identifier value for the entity to be instantiated.session
- The session from which is requests originates- Returns:
- The instantiated entity.
-
getIdentifier
@Deprecated java.io.Serializable getIdentifier(java.lang.Object entity) throws HibernateException
Deprecated.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 occurs accessing its value.
-
getIdentifier
java.io.Serializable getIdentifier(java.lang.Object entity, SharedSessionContractImplementor session)
Extract the identifier value from the given entity.- Parameters:
entity
- The entity from which to extract the identifier value.session
- The session from which is requests originates- Returns:
- The identifier value.
-
setIdentifier
@Deprecated void setIdentifier(java.lang.Object entity, java.io.Serializable id) throws HibernateException
Deprecated.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
-
setIdentifier
void setIdentifier(java.lang.Object entity, java.io.Serializable id, SharedSessionContractImplementor session)
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.session
- The session from which is requests originates
-
resetIdentifier
@Deprecated void resetIdentifier(java.lang.Object entity, java.io.Serializable currentId, java.lang.Object currentVersion)
Deprecated.Inject the given identifier and version into the entity, in order to "roll back" to their original values.- 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
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.- 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
java.lang.Object getVersion(java.lang.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
- Indicates a problem accessing the version property
-
setPropertyValue
void setPropertyValue(java.lang.Object entity, int i, java.lang.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
- Indicates a problem access the property
-
setPropertyValue
void setPropertyValue(java.lang.Object entity, java.lang.String propertyName, java.lang.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
- Indicates a problem access the property
-
getPropertyValuesToInsert
java.lang.Object[] getPropertyValuesToInsert(java.lang.Object entity, java.util.Map mergeMap, SharedSessionContractImplementor 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 instancessession
- The session in which the resuest is being made.- Returns:
- The insertable property values.
- Throws:
HibernateException
- Indicates a problem access the properties
-
getPropertyValue
java.lang.Object getPropertyValue(java.lang.Object entity, java.lang.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
- Indicates a problem access the property
-
afterInitialize
void afterInitialize(java.lang.Object entity, SharedSessionContractImplementor session)
Called just after the entities properties have been initialized.- Parameters:
entity
- The entity being initialized.session
- The session initializing this entity.
-
hasProxy
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
java.lang.Object createProxy(java.io.Serializable id, SharedSessionContractImplementor 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
boolean isLifecycleImplementor()
- Returns:
- True if the Lifecycle interface is implemented; false otherwise.
-
getConcreteProxyClass
java.lang.Class getConcreteProxyClass()
Returns the java class to which generated proxies will be typed. todo : look at fully encapsulatingPersistenceContext.narrowProxy(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.EntityKey, java.lang.Object)
here, since that is the only external use of this method- Returns:
- The java class to which generated proxies will be typed
-
getEntityNameResolvers
EntityNameResolver[] getEntityNameResolvers()
Get anyEntityNameResolvers
associated with thisTuplizer
.- Returns:
- The associated resolvers. May be null or empty.
-
determineConcreteSubclassEntityName
java.lang.String determineConcreteSubclassEntityName(java.lang.Object entityInstance, SessionFactoryImplementor factory)
Given an entity instance, determine the most appropriate (most targeted) entity-name which represents it. This is called in situations where we already know an entity name for the given entityInstance; we are being asked to determine if there is a more appropriate entity-name to use, specifically within an inheritence hierarchy. For example, consider a case where a user calls session.update( "Animal", cat );. Here, the user has explicitly provided Animal as the entity-name. However, they have passed in an instance of Cat which is a subclass of Animal. In this case, we would return Cat as the entity-name. null may be returned from calls to this method. The meaining of null in that case is assumed to be that we should use whatever explicit entity-name the user provided (Animal rather than Cat in the example above).- Parameters:
entityInstance
- The entity instance.factory
- Reference to the SessionFactory.- Returns:
- The most appropriate entity name to use.
- Throws:
HibernateException
- If we are unable to determine an entity-name within the inheritence hierarchy.
-
getIdentifierGetter
Getter getIdentifierGetter()
Retrieve the getter for the identifier property. May return null.- Returns:
- The getter for the identifier property.
-
getVersionGetter
Getter getVersionGetter()
Retrieve the getter for the version property. May return null.- Returns:
- The getter for the version property.
-
getProxyFactory
default ProxyFactory getProxyFactory()
-
-