Top Description Methods
org.hibernate.tuple.entity

public Interface EntityTuplizer

extends Tuplizer
Known Direct Implementers
org.hibernate.tuple.entity.AbstractEntityTuplizer
Imports
java.io.Serializable, java.util.Map, org.hibernate.EntityMode, .EntityNameResolver, .HibernateException, org.hibernate.engine.spi.SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.property.access.spi.Getter, org.hibernate.proxy.ProxyFactory, org.hibernate.tuple.Tuplizer

Defines further responsibilities regarding 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)

Authors
Gavin King, Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public void
afterInitialize(Object
The entity being initialized.
entity
,
SharedSessionContractImplementor
The session initializing this entity.
session
)

Called just after the entities properties have been initialized.

public Object

Returns:

The generate proxies.
createProxy
(Serializable
The id of the instance for which to generate a proxy.
id
,
SharedSessionContractImplementor
The session to which the proxy should be bound.
session
)

Generates an appropriate proxy representation of this entity for this entity-mode.

public String

Returns:

The most appropriate entity name to use.
determineConcreteSubclassEntityName
(Object
The entity instance.
entityInstance
,
SessionFactoryImplementor
Reference to the SessionFactory.
factory
)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Given an entity instance, determine the most appropriate (most targeted) entity-name which represents it.
public Class<T>

Returns:

The java class to which generated proxies will be typed
getConcreteProxyClass
()

Returns the java class to which generated proxies will be typed.

public EntityMode

Returns:

The entity-mode
getEntityMode
()

Return the entity-mode handled by this tuplizer instance.

public EntityNameResolver[]

Returns:

The associated resolvers. May be null or empty.
getEntityNameResolvers
()

Get any EntityNameResolvers associated with this Tuplizer.

public Serializable

Returns:

The identifier value.
getIdentifier
(Object
The entity from which to extract the identifier value.
entity
)

Extract the identifier value from the given entity.
public Serializable

Returns:

The identifier value.
getIdentifier
(Object
The entity from which to extract the identifier value.
entity
,
SharedSessionContractImplementor
The session from which is requests originates
session
)

Extract the identifier value from the given entity.

public Getter

Returns:

The getter for the identifier property.
getIdentifierGetter
()

Retrieve the getter for the identifier property.

public Object

Returns:

The current value of the given property on the given entity.
getPropertyValue
(Object
The entity from which to extract the property value.
entity
,
String
The name of the property for which to extract the value.
propertyName
)

Extract the value of a particular property from the given entity.

public Object[]

Returns:

The insertable property values.
getPropertyValuesToInsert
(Object
The entity from which to extract.
entity
,
Map<K, V>
a map of instances being merged to merged instances
mergeMap
,
SharedSessionContractImplementor
The session in which the result set is being made.
session
)

Extract the values of the insertable properties of the entity (including backrefs)

public default ProxyFactory
public Object

Returns:

The value of the version property, or null if not versioned.
getVersion
(Object
The entity from which to extract the version value.
entity
)

Extract the value of the version property from the given entity.

public Getter

Returns:

The getter for the version property.
getVersionGetter
()

Retrieve the getter for the version property.

public boolean

Returns:

True if this tuplizer can generate proxies for this entity.
hasProxy
()

Does this entity, for this mode, present a possibility for proxying?

public Object

Returns:

The instantiated entity.
instantiate
(Serializable
The identifier value for the entity to be instantiated.
id
)

Create an entity instance initialized with the given identifier.
public Object

Returns:

The instantiated entity.
instantiate
(Serializable
The identifier value for the entity to be instantiated.
id
,
SharedSessionContractImplementor
The session from which is requests originates
session
)

Create an entity instance initialized with the given identifier.

public boolean

Returns:

True if the Lifecycle interface is implemented; false otherwise.
isLifecycleImplementor
()

Does the class managed by this tuplizer implement the org.hibernate.classic.Lifecycle interface.

public void
resetIdentifier(Object
The entity for which to reset the id/version values
entity
,
Serializable
The identifier value to inject into the entity.
currentId
,
Object
The version value to inject into the entity.
currentVersion
)

Inject the given identifier and version into the entity, in order to "roll back" to their original values.
public void
resetIdentifier(Object
The entity for which to reset the id/version values
entity
,
Serializable
The identifier value to inject into the entity.
currentId
,
Object
The version value to inject into the entity.
currentVersion
,
SharedSessionContractImplementor
The session from which the request originated
session
)

Inject the given identifier and version into the entity, in order to "roll back" to their original values.

public void
setIdentifier(Object
The entity to inject with the identifier value.
entity
,
Serializable
The value to be injected as the identifier.
id
)

Inject the identifier value into the given entity.
public void
setIdentifier(Object
The entity to inject with the identifier value.
entity
,
Serializable
The value to be injected as the identifier.
id
,
SharedSessionContractImplementor
The session from which is requests originates
session
)

Inject the identifier value into the given entity.

public void
setPropertyValue(Object
The entity into which to inject the value.
entity
,
int
The property's index.
i
,
Object
The property value to inject.
value
)

Inject the value of a particular property.

public void
setPropertyValue(Object
The entity into which to inject the value.
entity
,
String
The name of the property.
propertyName
,
Object
The property value to inject.
value
)

Inject the value of a particular property.

Inherited from org.hibernate.tuple.Tuplizer:
getGettergetMappedClassgetPropertyValuegetPropertyValuesinstantiateisInstancesetPropertyValues

Method Detail

afterInitializeback to summary
public void afterInitialize(Object entity, SharedSessionContractImplementor session)

Called just after the entities properties have been initialized.

Parameters
entity:Object

The entity being initialized.

session:SharedSessionContractImplementor

The session initializing this entity.

createProxyback to summary
public Object createProxy(Serializable id, SharedSessionContractImplementor session) throws HibernateException

Generates an appropriate proxy representation of this entity for this entity-mode.

Parameters
id:Serializable

The id of the instance for which to generate a proxy.

session:SharedSessionContractImplementor

The session to which the proxy should be bound.

Returns:Object

The generate proxies.

Exceptions
HibernateException:
Indicates an error generating the proxy.
determineConcreteSubclassEntityNameback to summary
public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

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 inheritance 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 meaning 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:Object

The entity instance.

factory:SessionFactoryImplementor

Reference to the SessionFactory.

Returns:String

The most appropriate entity name to use.

Exceptions
HibernateException:
If we are unable to determine an entity-name within the inheritance hierarchy.
getConcreteProxyClassback to summary
public Class<T> getConcreteProxyClass()

Returns the java class to which generated proxies will be typed.

todo : look at fully encapsulating org.hibernate.engine.spi.PersistenceContext#narrowProxy here, since that is the only external use of this method

Returns:Class<T>

The java class to which generated proxies will be typed

getEntityModeback to summary
public EntityMode getEntityMode()

Return the entity-mode handled by this tuplizer instance.

Returns:EntityMode

The entity-mode

getEntityNameResolversback to summary
public EntityNameResolver[] getEntityNameResolvers()

Get any EntityNameResolvers associated with this Tuplizer.

Returns:EntityNameResolver[]

The associated resolvers. May be null or empty.

getIdentifierback to summary
public Serializable getIdentifier(Object entity) throws HibernateException

Extract the identifier value from the given entity.

Parameters
entity:Object

The entity from which to extract the identifier value.

Returns:Serializable

The identifier value.

Annotations
@Deprecated
Exceptions
HibernateException:
If the entity does not define an identifier property, or an error occurs accessing its value.
getIdentifierback to summary
public Serializable getIdentifier(Object entity, SharedSessionContractImplementor session)

Extract the identifier value from the given entity.

Parameters
entity:Object

The entity from which to extract the identifier value.

session:SharedSessionContractImplementor

The session from which is requests originates

Returns:Serializable

The identifier value.

getIdentifierGetterback to summary
public Getter getIdentifierGetter()

Retrieve the getter for the identifier property. May return null.

Returns:Getter

The getter for the identifier property.

getPropertyValueback to summary
public Object getPropertyValue(Object entity, String propertyName) throws HibernateException

Extract the value of a particular property from the given entity.

Parameters
entity:Object

The entity from which to extract the property value.

propertyName:String

The name of the property for which to extract the value.

Returns:Object

The current value of the given property on the given entity.

Exceptions
HibernateException:
Indicates a problem access the property
getPropertyValuesToInsertback to summary
public Object[] getPropertyValuesToInsert(Object entity, Map<K, V> mergeMap, SharedSessionContractImplementor session) throws HibernateException

Extract the values of the insertable properties of the entity (including backrefs)

Parameters
entity:Object

The entity from which to extract.

mergeMap:Map<K, V>

a map of instances being merged to merged instances

session:SharedSessionContractImplementor

The session in which the result set is being made.

Returns:Object[]

The insertable property values.

Exceptions
HibernateException:
Indicates a problem access the properties
getProxyFactoryback to summary
public default ProxyFactory getProxyFactory()
getVersionback to summary
public Object getVersion(Object entity) throws HibernateException

Extract the value of the version property from the given entity.

Parameters
entity:Object

The entity from which to extract the version value.

Returns:Object

The value of the version property, or null if not versioned.

Exceptions
HibernateException:
Indicates a problem accessing the version property
getVersionGetterback to summary
public Getter getVersionGetter()

Retrieve the getter for the version property. May return null.

Returns:Getter

The getter for the version property.

hasProxyback to summary
public boolean hasProxy()

Does this entity, for this mode, present a possibility for proxying?

Returns:boolean

True if this tuplizer can generate proxies for this entity.

instantiateback to summary
public Object instantiate(Serializable id) throws HibernateException

Create an entity instance initialized with the given identifier.

Parameters
id:Serializable

The identifier value for the entity to be instantiated.

Returns:Object

The instantiated entity.

Annotations
@Deprecated
@SuppressWarnings:JavaDoc
instantiateback to summary
public Object instantiate(Serializable id, SharedSessionContractImplementor session)

Create an entity instance initialized with the given identifier.

Parameters
id:Serializable

The identifier value for the entity to be instantiated.

session:SharedSessionContractImplementor

The session from which is requests originates

Returns:Object

The instantiated entity.

isLifecycleImplementorback to summary
public boolean isLifecycleImplementor()

Does the class managed by this tuplizer implement the org.hibernate.classic.Lifecycle interface.

Returns:boolean

True if the Lifecycle interface is implemented; false otherwise.

resetIdentifierback to summary
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
entity:Object

The entity for which to reset the id/version values

currentId:Serializable

The identifier value to inject into the entity.

currentVersion:Object

The version value to inject into the entity.

Annotations
@Deprecated
@SuppressWarnings:UnusedDeclaration
resetIdentifierback to summary
public 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.

Parameters
entity:Object

The entity for which to reset the id/version values

currentId:Serializable

The identifier value to inject into the entity.

currentVersion:Object

The version value to inject into the entity.

session:SharedSessionContractImplementor

The session from which the request originated

setIdentifierback to summary
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:Object

The entity to inject with the identifier value.

id:Serializable

The value to be injected as the identifier.

Annotations
@Deprecated
@SuppressWarnings:JavaDoc
setIdentifierback to summary
public void setIdentifier(Object entity, 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:Object

The entity to inject with the identifier value.

id:Serializable

The value to be injected as the identifier.

session:SharedSessionContractImplementor

The session from which is requests originates

setPropertyValueback to summary
public void setPropertyValue(Object entity, int i, Object value) throws HibernateException

Inject the value of a particular property.

Parameters
entity:Object

The entity into which to inject the value.

i:int

The property's index.

value:Object

The property value to inject.

Exceptions
HibernateException:
Indicates a problem access the property
setPropertyValueback to summary
public void setPropertyValue(Object entity, String propertyName, Object value) throws HibernateException

Inject the value of a particular property.

Parameters
entity:Object

The entity into which to inject the value.

propertyName:String

The name of the property.

value:Object

The property value to inject.

Exceptions
HibernateException:
Indicates a problem access the property