FileDocCategorySizeDatePackage
EntityPersister.javaAPI DocHibernate 3.2.521188Fri Jan 19 05:55:08 GMT 2007org.hibernate.persister.entity

EntityPersister

public interface EntityPersister implements org.hibernate.cache.OptimisticCacheSource
Implementors define mapping and persistence logic for a particular strategy of entity mapping. An instance of entity persisters corresponds to a given mapped entity.

Implementors must be threadsafe (preferrably immutable) and must provide a constructor matching the signature of: {@link org.hibernate.mapping.PersistentClass}, {@link org.hibernate.engine.SessionFactoryImplementor}

author
Gavin King

Fields Summary
public static final String
ENTITY_ID
The property name of the "special" identifier property in HQL
Constructors Summary
Methods Summary
public voidafterInitialize(java.lang.Object entity, boolean lazyPropertiesAreUnfetched, org.hibernate.engine.SessionImplementor session)
Called just after the entities properties have been initialized

public voidafterReassociate(java.lang.Object entity, org.hibernate.engine.SessionImplementor session)
Called just after the entity has been reassociated with the session

public booleancanExtractIdOutOfEntity()
Determine whether detahced instances of this entity carry their own identifier value.

The other option is the deperecated feature where users could supply the id during session calls.

return
True if either (1) {@link #hasIdentifierProperty()} or (2) the identifier is an embedded composite identifier; false otherwise.

public java.lang.ObjectcreateProxy(java.io.Serializable id, org.hibernate.engine.SessionImplementor session)
Create a new proxy instance

public voiddelete(java.io.Serializable id, java.lang.Object version, java.lang.Object object, org.hibernate.engine.SessionImplementor session)
Delete a persistent instance

public int[]findDirty(java.lang.Object[] currentState, java.lang.Object[] previousState, java.lang.Object owner, org.hibernate.engine.SessionImplementor session)
Compare the two snapshots to determine if they represent dirty state.

param
currentState The current snapshot
param
previousState The baseline snapshot
param
owner The entity containing the state
param
session The originating session
return
The indices of all dirty properties, or null if no properties were dirty.

public int[]findModified(java.lang.Object[] old, java.lang.Object[] current, java.lang.Object object, org.hibernate.engine.SessionImplementor session)
Compare the two snapshots to determine if they represent modified state.

param
old The baseline snapshot
param
current The current snapshot
param
object The entity containing the state
param
session The originating session
return
The indices of all modified properties, or null if no properties were modified.

public java.lang.ObjectforceVersionIncrement(java.io.Serializable id, java.lang.Object currentVersion, org.hibernate.engine.SessionImplementor session)

public org.hibernate.cache.CacheConcurrencyStrategygetCache()
Get the cache (optional operation)

public org.hibernate.cache.entry.CacheEntryStructuregetCacheEntryStructure()
Get the cache structure

public org.hibernate.metadata.ClassMetadatagetClassMetadata()
Get the user-visible metadata for the class (optional operation)

public java.lang.ClassgetConcreteProxyClass(org.hibernate.EntityMode entityMode)
Get the proxy interface that instances of this concrete class will be cast to (optional operation).

public java.lang.ObjectgetCurrentVersion(java.io.Serializable id, org.hibernate.engine.SessionImplementor session)
Get the current version of the object, or return null if there is no row for the given identifier. In the case of unversioned data, return any object if the row exists.

public java.lang.Object[]getDatabaseSnapshot(java.io.Serializable id, org.hibernate.engine.SessionImplementor session)
Get the current database state of the object, in a "hydrated" form, without resolving identifiers

return
null if there is no row in the database

public org.hibernate.tuple.entity.EntityMetamodelgetEntityMetamodel()
Retrieve the underlying entity metamodel instance...

return
The metamodel

public java.lang.StringgetEntityName()
The entity name which this persister maps.

return
The name of the entity which this persister maps.

public org.hibernate.engine.SessionFactoryImplementorgetFactory()
Return the SessionFactory to which this persister "belongs".

return
The owning SessionFactory.

public java.io.SerializablegetIdentifier(java.lang.Object object, org.hibernate.EntityMode entityMode)
Get the identifier of an instance (throw an exception if no identifier property)

public org.hibernate.id.IdentifierGeneratorgetIdentifierGenerator()
Determine which identifier generation strategy is used for this entity.

return
The identifier generation strategy.

public java.lang.StringgetIdentifierPropertyName()
Get the name of the identifier property (or return null) - need not return the name of an actual Java property

public org.hibernate.type.TypegetIdentifierType()
Get the identifier type

public java.lang.ClassgetMappedClass(org.hibernate.EntityMode entityMode)
The persistent class, or null

public int[]getNaturalIdentifierProperties()
If the entity defines a natural id ({@link #hasNaturalIdentifier()}), which properties make up the natural id.

return
The indices of the properties making of the natural id; or null, if no natural id is defined.

public java.lang.Object[]getNaturalIdentifierSnapshot(java.io.Serializable id, org.hibernate.engine.SessionImplementor session)
Retrieve the current state of the natural-id properties from the database.

param
id The identifier of the entity for which to retrieve the naturak-id values.
param
session The session from which the request originated.
return
The natural-id snapshot.

public org.hibernate.engine.CascadeStyle[]getPropertyCascadeStyles()
Get the cascade styles of the propertes (optional operation)

public boolean[]getPropertyCheckability()
Get the "checkability" of the properties of this class (is the property dirty checked, does the cache need to be updated)

public org.hibernate.engine.ValueInclusion[]getPropertyInsertGenerationInclusions()
Which of the properties of this class are database generated values on insert?

public boolean[]getPropertyInsertability()
Get the "insertability" of the properties of this class (does the property appear in an SQL INSERT)

public boolean[]getPropertyLaziness()

public java.lang.String[]getPropertyNames()
Get the names of the class properties - doesn't have to be the names of the actual Java properties (used for XML generation only)

public boolean[]getPropertyNullability()
Get the nullability of the properties of this class

public java.io.Serializable[]getPropertySpaces()
Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class only.

For most implementations, this returns the complete set of table names to which instances of the mapped entity are persisted (not accounting for superclass entity mappings).

return
The property spaces.

public org.hibernate.type.TypegetPropertyType(java.lang.String propertyName)
Get the type of a particular property by name.

param
propertyName The name of the property for which to retrieve the typpe.
return
The type.
throws
org.hibernate.MappingException Typically indicates an unknown property name.

public org.hibernate.type.Type[]getPropertyTypes()
Get the Hibernate types of the class properties

public org.hibernate.engine.ValueInclusion[]getPropertyUpdateGenerationInclusions()
Which of the properties of this class are database generated values on update?

public boolean[]getPropertyUpdateability()
Get the "updateability" of the properties of this class (does the property appear in an SQL UPDATE)

public java.lang.ObjectgetPropertyValue(java.lang.Object object, int i, org.hibernate.EntityMode entityMode)
Get the value of a particular property

public java.lang.ObjectgetPropertyValue(java.lang.Object object, java.lang.String propertyName, org.hibernate.EntityMode entityMode)
Get the value of a particular property

public java.lang.Object[]getPropertyValues(java.lang.Object object, org.hibernate.EntityMode entityMode)
Return the (loaded) values of the mapped properties of the object (not including backrefs)

public java.lang.Object[]getPropertyValuesToInsert(java.lang.Object object, java.util.Map mergeMap, org.hibernate.engine.SessionImplementor session)
Return the values of the insertable properties of the object (including backrefs)

public boolean[]getPropertyVersionability()
Get the "versionability" of the properties of this class (is the property optimistic-locked)

public java.io.Serializable[]getQuerySpaces()
Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class and its subclasses.

Much like {@link #getPropertySpaces()}, except that here we include subclass entity spaces.

return
The query spaces.

public java.lang.StringgetRootEntityName()
Returns an object that identifies the space in which identifiers of this entity hierarchy are unique. Might be a table name, a JNDI URL, etc.

return
The root entity name.

public org.hibernate.persister.entity.EntityPersistergetSubclassEntityPersister(java.lang.Object instance, org.hibernate.engine.SessionFactoryImplementor factory, org.hibernate.EntityMode entityMode)
Get the persister for an instance of this class or a subclass

public java.lang.ObjectgetVersion(java.lang.Object object, org.hibernate.EntityMode entityMode)
Get the version number (or timestamp) from the object's version property (or return null if not versioned)

public intgetVersionProperty()
If {@link #isVersioned()}, then what is the index of the property holding the locking value.

return
The type of the version property; or -66, if not versioned.

public org.hibernate.type.VersionTypegetVersionType()
If {@link #isVersioned()}, then what is the type of the property holding the locking value.

return
The type of the version property; or null, if not versioned.

public org.hibernate.EntityModeguessEntityMode(java.lang.Object object)
Try to discover the entity mode from the entity instance

public booleanhasCache()
Does this class have a cache.

public booleanhasCascades()
Determine whether this entity has any non-none cascading.

return
True if the entity has any properties with a cscade other than NONE; false otherwise (aka, no cascading).

public booleanhasCollections()
Determine whether this entity contains references to persistent collections.

return
True if the entity does contain persistent collections; false otherwise.

public booleanhasIdentifierProperty()
Determine whether the entity has a particular property holding the identifier value.

return
True if the entity has a specific property holding identifier value.

public booleanhasInsertGeneratedProperties()
Does this entity define any properties as being database generated on insert?

return
True if this entity contains at least one property defined as generated (including version property, but not identifier).

public booleanhasLazyProperties()
Determine whether this entity defines any lazy properties (ala bytecode instrumentation).

return
True if the entity has properties mapped as lazy; false otherwise.

public booleanhasMutableProperties()
Determine whether any properties of this entity are considered mutable.

return
True if any properties of the entity are mutable; false otherwise (meaning none are).

public booleanhasNaturalIdentifier()
Determine whether this entity defines a natural identifier.

return
True if the entity defines a natural id; false otherwise.

public booleanhasProxy()
Determine whether this entity supports dynamic proxies.

return
True if the entity has dynamic proxy support; false otherwise.

public booleanhasSubselectLoadableCollections()
Determine whether this entity contains references to persistent collections which are fetchable by subselect?

return
True if the entity contains collections fetchable by subselect; false otherwise.

public booleanhasUninitializedLazyProperties(java.lang.Object object, org.hibernate.EntityMode entityMode)
Does the given instance have any uninitialized lazy properties?

public booleanhasUpdateGeneratedProperties()
Does this entity define any properties as being database generated on update?

return
True if this entity contains at least one property defined as generated (including version property, but not identifier).

public booleanimplementsLifecycle(org.hibernate.EntityMode entityMode)
Does the class implement the Lifecycle interface.

public booleanimplementsValidatable(org.hibernate.EntityMode entityMode)
Does the class implement the Validatable interface.

public voidinsert(java.io.Serializable id, java.lang.Object[] fields, java.lang.Object object, org.hibernate.engine.SessionImplementor session)
Persist an instance

public java.io.Serializableinsert(java.lang.Object[] fields, java.lang.Object object, org.hibernate.engine.SessionImplementor session)
Persist an instance, using a natively generated identifier (optional operation)

public java.lang.Objectinstantiate(java.io.Serializable id, org.hibernate.EntityMode entityMode)
Create a class instance initialized with the given identifier

public booleanisBatchLoadable()
Is batch loading enabled?

public booleanisCacheInvalidationRequired()
Should we always invalidate the cache instead of recaching updated state

public booleanisIdentifierAssignedByInsert()
Are identifiers of this entity assigned known before the insert execution? Or, are they generated (in the database) by the insert execution.

return
True if identifiers for this entity are generated by the insert execution.

public booleanisInherited()
Determine whether the entity is inherited one or more other entities. In other words, is this entity a subclass of other entities.

return
True if other entities extend this entity; false otherwise.

public booleanisInstance(java.lang.Object object, org.hibernate.EntityMode entityMode)
Is the given object an instance of this entity?

public booleanisInstrumented(org.hibernate.EntityMode entityMode)
Has the class actually been bytecode instrumented?

public booleanisLazyPropertiesCacheable()
Should lazy properties of this entity be cached?

public booleanisMutable()
Determine whether instances of this entity are considered mutable.

return
True if the entity is considered mutable; false otherwise.

public booleanisSelectBeforeUpdateRequired()
Is select snapshot before update enabled?

public booleanisSubclassEntityName(java.lang.String entityName)
Determine whether the given name represents a subclass entity (or this entity itself) of the entity mapped by this persister.

param
entityName The entity name to be checked.
return
True if the given entity name represents either the entity mapped by this persister or one of its subclass entities; false otherwise.

public java.lang.BooleanisTransient(java.lang.Object object, org.hibernate.engine.SessionImplementor session)
Is this a new transient instance?

public booleanisVersionPropertyGenerated()
Does this entity contain a version property that is defined to be database generated?

return
true if this entity contains a version property and that property has been marked as generated.

public booleanisVersioned()
Determine whether optimistic locking by column is enabled for this entity.

return
True if optimistic locking by column (i.e., or ) is enabled; false otherwise.

public java.lang.Objectload(java.io.Serializable id, java.lang.Object optionalObject, org.hibernate.LockMode lockMode, org.hibernate.engine.SessionImplementor session)
Load an instance of the persistent class.

public voidlock(java.io.Serializable id, java.lang.Object version, java.lang.Object object, org.hibernate.LockMode lockMode, org.hibernate.engine.SessionImplementor session)
Do a version check (optional operation)

public voidpostInstantiate()
Finish the initialization of this object.

Called only once per {@link org.hibernate.SessionFactory} lifecycle, after all entity persisters have been instantiated.

throws
org.hibernate.MappingException Indicates an issue in the metdata.

public voidprocessInsertGeneratedProperties(java.io.Serializable id, java.lang.Object entity, java.lang.Object[] state, org.hibernate.engine.SessionImplementor session)
Perform a select to retrieve the values of any generated properties back from the database, injecting these generated values into the given entity as well as writing this state to the {@link org.hibernate.engine.PersistenceContext}.

Note, that because we update the PersistenceContext here, callers need to take care that they have already written the initial snapshot to the PersistenceContext before calling this method.

param
id The entity's id value.
param
entity The entity for which to get the state.
param
state
param
session The session

public voidprocessUpdateGeneratedProperties(java.io.Serializable id, java.lang.Object entity, java.lang.Object[] state, org.hibernate.engine.SessionImplementor session)
Perform a select to retrieve the values of any generated properties back from the database, injecting these generated values into the given entity as well as writing this state to the {@link org.hibernate.engine.PersistenceContext}.

Note, that because we update the PersistenceContext here, callers need to take care that they have already written the initial snapshot to the PersistenceContext before calling this method.

param
id The entity's id value.
param
entity The entity for which to get the state.
param
state
param
session The session

public voidresetIdentifier(java.lang.Object entity, java.io.Serializable currentId, java.lang.Object currentVersion, org.hibernate.EntityMode entityMode)
Set the identifier and version of the given instance back to its "unsaved" value, returning the id

param
currentId TODO
param
currentVersion TODO

public voidsetIdentifier(java.lang.Object object, java.io.Serializable id, org.hibernate.EntityMode entityMode)
Set the identifier of an instance (or do nothing if no identifier property)

public voidsetPropertyValue(java.lang.Object object, int i, java.lang.Object value, org.hibernate.EntityMode entityMode)
Set the value of a particular property

public voidsetPropertyValues(java.lang.Object object, java.lang.Object[] values, org.hibernate.EntityMode entityMode)
Set the given values to the mapped properties of the given object

public voidupdate(java.io.Serializable id, java.lang.Object[] fields, int[] dirtyFields, boolean hasDirtyCollection, java.lang.Object[] oldFields, java.lang.Object oldVersion, java.lang.Object object, java.lang.Object rowId, org.hibernate.engine.SessionImplementor session)
Update a persistent instance