public interface EntityTuplizer extends Tuplizer
Defines further responsibilities reagarding tuplization based on a mapped entity. <p/> 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)
Modifier and Type | Method and Description |
---|---|
void |
afterInitialize(Object entity,
SharedSessionContractImplementor session)
Called just after the entities properties have been initialized.
|
Object |
createProxy(Serializable id,
SharedSessionContractImplementor session)
Generates an appropriate proxy representation of this entity for this
entity-mode.
|
String |
determineConcreteSubclassEntityName(Object entityInstance,
SessionFactoryImplementor factory)
Given an entity instance, determine the most appropriate (most targeted) entity-name which represents it.
|
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 any
EntityNameResolvers associated with this Tuplizer . |
Serializable |
getIdentifier(Object entity)
Deprecated.
|
Serializable |
getIdentifier(Object entity,
SharedSessionContractImplementor session)
Extract the identifier value from the given entity.
|
Getter |
getIdentifierGetter()
Retrieve the getter for the identifier property.
|
Object |
getPropertyValue(Object entity,
String propertyName)
Extract the value of a particular property from the given entity.
|
Object[] |
getPropertyValuesToInsert(Object entity,
Map mergeMap,
SharedSessionContractImplementor 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.
|
Getter |
getVersionGetter()
Retrieve the getter for the version property.
|
boolean |
hasProxy()
Does this entity, for this mode, present a possibility for proxying?
|
Object |
instantiate(Serializable id)
Deprecated.
|
Object |
instantiate(Serializable id,
SharedSessionContractImplementor session)
Create an entity instance initialized with the given identifier.
|
boolean |
isLifecycleImplementor()
|
void |
resetIdentifier(Object entity,
Serializable currentId,
Object currentVersion)
Deprecated.
|
void |
resetIdentifier(Object entity,
Serializable currentId,
Object currentVersion,
SharedSessionContractImplementor session)
Inject the given identifier and version into the entity, in order to
"roll back" to their original values.
|
void |
setIdentifier(Object entity,
Serializable id)
Deprecated.
|
void |
setIdentifier(Object entity,
Serializable id,
SharedSessionContractImplementor session)
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.
|
getGetter, getMappedClass, getPropertyValue, getPropertyValues, instantiate, isInstance, setPropertyValues
EntityMode getEntityMode()
Return the entity-mode handled by this tuplizer instance.
@Deprecated Object instantiate(Serializable id) throws HibernateException
instantiate(Serializable, SharedSessionContractImplementor)
instead.Create an entity instance initialized with the given identifier.
id
- The identifier value for the entity to be instantiated.HibernateException
Object instantiate(Serializable id, SharedSessionContractImplementor session)
Create an entity instance initialized with the given identifier.
id
- The identifier value for the entity to be instantiated.session
- The session from which is requests originates@Deprecated Serializable getIdentifier(Object entity) throws HibernateException
getIdentifier(Object,SharedSessionContractImplementor)
instead.Extract the identifier value from the given entity.
entity
- The entity from which to extract the identifier value.HibernateException
- If the entity does not define an identifier property, or an
error occurs accessing its value.Serializable getIdentifier(Object entity, SharedSessionContractImplementor session)
Extract the identifier value from the given entity.
entity
- The entity from which to extract the identifier value.session
- The session from which is requests originates@Deprecated void setIdentifier(Object entity, Serializable id) throws HibernateException
setIdentifier(Object, Serializable, SharedSessionContractImplementor)
instead.Inject the identifier value into the given entity. </p> Has no effect if the entity does not define an identifier property
entity
- The entity to inject with the identifier value.id
- The value to be injected as the identifier.HibernateException
void setIdentifier(Object entity, Serializable id, SharedSessionContractImplementor session)
Inject the identifier value into the given entity. </p> Has no effect if the entity does not define an identifier property
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@Deprecated void resetIdentifier(Object entity, Serializable currentId, Object currentVersion)
resetIdentifier(Object, Serializable, Object, SharedSessionContractImplementor)
insteadInject the given identifier and version into the entity, in order to "roll back" to their original values.
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.void resetIdentifier(Object entity, Serializable currentId, Object currentVersion, SharedSessionContractImplementor session)
Inject the given identifier and version into the entity, in order to "roll back" to their original values.
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 originatedObject getVersion(Object entity) throws HibernateException
Extract the value of the version property from the given entity.
entity
- The entity from which to extract the version value.HibernateException
- Indicates a problem accessing the version propertyvoid setPropertyValue(Object entity, int i, Object value) throws HibernateException
Inject the value of a particular property.
entity
- The entity into which to inject the value.i
- The property’s index.value
- The property value to inject.HibernateException
- Indicates a problem access the propertyvoid setPropertyValue(Object entity, String propertyName, Object value) throws HibernateException
Inject the value of a particular property.
entity
- The entity into which to inject the value.propertyName
- The name of the property.value
- The property value to inject.HibernateException
- Indicates a problem access the propertyObject[] getPropertyValuesToInsert(Object entity, Map mergeMap, SharedSessionContractImplementor session) throws HibernateException
Extract the values of the insertable properties of the entity (including backrefs)
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.HibernateException
- Indicates a problem access the propertiesObject getPropertyValue(Object entity, String propertyName) throws HibernateException
Extract the value of a particular property from the given entity.
entity
- The entity from which to extract the property value.propertyName
- The name of the property for which to extract the value.HibernateException
- Indicates a problem access the propertyvoid afterInitialize(Object entity, SharedSessionContractImplementor session)
Called just after the entities properties have been initialized.
entity
- The entity being initialized.session
- The session initializing this entity.boolean hasProxy()
Does this entity, for this mode, present a possibility for proxying?
Object createProxy(Serializable id, SharedSessionContractImplementor session) throws HibernateException
Generates an appropriate proxy representation of this entity for this entity-mode.
id
- The id of the instance for which to generate a proxy.session
- The session to which the proxy should be bound.HibernateException
- Indicates an error generating the proxy.boolean isLifecycleImplementor()
Class getConcreteProxyClass()
Returns the java class to which generated proxies will be typed.
<p/>
todo : look at fully encapsulating PersistenceContext.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
EntityNameResolver[] getEntityNameResolvers()
Get any EntityNameResolvers
associated with this Tuplizer
.
String determineConcreteSubclassEntityName(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. <p/> For example, consider a case where a user calls <tt>session.update( "Animal", cat );</tt>. Here, the user has explicitly provided <tt>Animal</tt> as the entity-name. However, they have passed in an instance of <tt>Cat</tt> which is a subclass of <tt>Animal</tt>. In this case, we would return <tt>Cat</tt> as the entity-name. <p/> <tt>null</tt> may be returned from calls to this method. The meaining of <tt>null</tt> in that case is assumed to be that we should use whatever explicit entity-name the user provided (<tt>Animal</tt> rather than <tt>Cat</tt> in the example above).
entityInstance
- The entity instance.factory
- Reference to the SessionFactory.HibernateException
- If we are unable to determine an entity-name within the inheritence hierarchy.Getter getIdentifierGetter()
Retrieve the getter for the identifier property. May return null.
Getter getVersionGetter()
Retrieve the getter for the version property. May return null.
Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.