|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface EntityPersister
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:PersistentClass
, SessionFactoryImplementor
Field Summary | |
---|---|
static String |
ENTITY_ID
The property name of the "special" identifier property in HQL |
Method Summary | |
---|---|
void |
afterInitialize(Object entity,
boolean lazyPropertiesAreUnfetched,
SessionImplementor session)
Called just after the entities properties have been initialized |
void |
afterReassociate(Object entity,
SessionImplementor session)
Called just after the entity has been reassociated with the session |
boolean |
canExtractIdOutOfEntity()
Determine whether detached instances of this entity carry their own identifier value. |
Object |
createProxy(Serializable id,
SessionImplementor session)
Create a new proxy instance |
void |
delete(Serializable id,
Object version,
Object object,
SessionImplementor session)
Delete a persistent instance |
int[] |
findDirty(Object[] currentState,
Object[] previousState,
Object owner,
SessionImplementor session)
Compare the two snapshots to determine if they represent dirty state. |
int[] |
findModified(Object[] old,
Object[] current,
Object object,
SessionImplementor session)
Compare the two snapshots to determine if they represent modified state. |
Object |
forceVersionIncrement(Serializable id,
Object currentVersion,
SessionImplementor session)
|
EntityRegionAccessStrategy |
getCacheAccessStrategy()
Get the cache (optional operation) |
CacheEntryStructure |
getCacheEntryStructure()
Get the cache structure |
ClassMetadata |
getClassMetadata()
Get the user-visible metadata for the class (optional operation) |
Class |
getConcreteProxyClass(EntityMode entityMode)
Get the proxy interface that instances of this concrete class will be cast to (optional operation). |
Object |
getCurrentVersion(Serializable id,
SessionImplementor session)
Get the current version of the object, or return null if there is no row for the given identifier. |
Object[] |
getDatabaseSnapshot(Serializable id,
SessionImplementor session)
Get the current database state of the object, in a "hydrated" form, without resolving identifiers |
EntityMetamodel |
getEntityMetamodel()
Retrieve the underlying entity metamodel instance... |
String |
getEntityName()
The entity name which this persister maps. |
SessionFactoryImplementor |
getFactory()
Return the SessionFactory to which this persister "belongs". |
Serializable |
getIdentifier(Object object,
EntityMode entityMode)
Deprecated. Use getIdentifier(Object,SessionImplementor) instead |
Serializable |
getIdentifier(Object entity,
SessionImplementor session)
Get the identifier of an instance (throw an exception if no identifier property) |
IdentifierGenerator |
getIdentifierGenerator()
Determine which identifier generation strategy is used for this entity. |
String |
getIdentifierPropertyName()
Get the name of the identifier property (or return null) - need not return the name of an actual Java property |
Type |
getIdentifierType()
Get the identifier type |
Class |
getMappedClass(EntityMode entityMode)
The persistent class, or null |
int[] |
getNaturalIdentifierProperties()
If the entity defines a natural id ( hasNaturalIdentifier() ), which
properties make up the natural id. |
Object[] |
getNaturalIdentifierSnapshot(Serializable id,
SessionImplementor session)
Retrieve the current state of the natural-id properties from the database. |
CascadeStyle[] |
getPropertyCascadeStyles()
Get the cascade styles of the properties (optional operation) |
boolean[] |
getPropertyCheckability()
Get the "checkability" of the properties of this class (is the property dirty checked, does the cache need to be updated) |
boolean[] |
getPropertyInsertability()
Get the "insertability" of the properties of this class (does the property appear in an SQL INSERT) |
ValueInclusion[] |
getPropertyInsertGenerationInclusions()
Which of the properties of this class are database generated values on insert? |
boolean[] |
getPropertyLaziness()
|
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) |
boolean[] |
getPropertyNullability()
Get the nullability of the properties of this class |
Serializable[] |
getPropertySpaces()
Returns an array of objects that identify spaces in which properties of this entity are persisted, for instances of this class only. |
Type |
getPropertyType(String propertyName)
Get the type of a particular property by name. |
Type[] |
getPropertyTypes()
Get the Hibernate types of the class properties |
boolean[] |
getPropertyUpdateability()
Get the "updateability" of the properties of this class (does the property appear in an SQL UPDATE) |
ValueInclusion[] |
getPropertyUpdateGenerationInclusions()
Which of the properties of this class are database generated values on update? |
Object |
getPropertyValue(Object object,
int i,
EntityMode entityMode)
Get the value of a particular property |
Object |
getPropertyValue(Object object,
String propertyName,
EntityMode entityMode)
Get the value of a particular property |
Object[] |
getPropertyValues(Object object,
EntityMode entityMode)
Return the (loaded) values of the mapped properties of the object (not including backrefs) |
Object[] |
getPropertyValuesToInsert(Object object,
Map mergeMap,
SessionImplementor session)
Return the values of the insertable properties of the object (including backrefs) |
boolean[] |
getPropertyVersionability()
Get the "versionability" of the properties of this class (is the property optimistic-locked) |
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. |
String |
getRootEntityName()
Returns an object that identifies the space in which identifiers of this entity hierarchy are unique. |
EntityPersister |
getSubclassEntityPersister(Object instance,
SessionFactoryImplementor factory,
EntityMode entityMode)
A request has already identified the entity-name of this persister as the mapping for the given instance. |
Object |
getVersion(Object object,
EntityMode entityMode)
Get the version number (or timestamp) from the object's version property (or return null if not versioned) |
int |
getVersionProperty()
If isVersioned() , then what is the index of the property
holding the locking value. |
VersionType |
getVersionType()
If isVersioned() , then what is the type of the property
holding the locking value. |
EntityMode |
guessEntityMode(Object object)
Try to discover the entity mode from the entity instance |
boolean |
hasCache()
Does this class have a cache. |
boolean |
hasCascades()
Determine whether this entity has any non-none cascading. |
boolean |
hasCollections()
Determine whether this entity contains references to persistent collections. |
boolean |
hasIdentifierProperty()
Determine whether the entity has a particular property holding the identifier value. |
boolean |
hasInsertGeneratedProperties()
Does this entity define any properties as being database generated on insert? |
boolean |
hasLazyProperties()
Determine whether this entity defines any lazy properties (ala bytecode instrumentation). |
boolean |
hasMutableProperties()
Determine whether any properties of this entity are considered mutable. |
boolean |
hasNaturalIdentifier()
Determine whether this entity defines a natural identifier. |
boolean |
hasProxy()
Determine whether this entity supports dynamic proxies. |
boolean |
hasSubselectLoadableCollections()
Determine whether this entity contains references to persistent collections which are fetchable by subselect? |
boolean |
hasUninitializedLazyProperties(Object object,
EntityMode entityMode)
Does the given instance have any uninitialized lazy properties? |
boolean |
hasUpdateGeneratedProperties()
Does this entity define any properties as being database generated on update? |
boolean |
implementsLifecycle(EntityMode entityMode)
Does the class implement the Lifecycle interface. |
boolean |
implementsValidatable(EntityMode entityMode)
Does the class implement the Validatable interface. |
Serializable |
insert(Object[] fields,
Object object,
SessionImplementor session)
Persist an instance, using a natively generated identifier (optional operation) |
void |
insert(Serializable id,
Object[] fields,
Object object,
SessionImplementor session)
Persist an instance |
Object |
instantiate(Serializable id,
EntityMode entityMode)
Deprecated. Use instantiate(Serializable, SessionImplementor) instead |
Object |
instantiate(Serializable id,
SessionImplementor session)
Create a class instance initialized with the given identifier |
boolean |
isBatchLoadable()
Is batch loading enabled? |
boolean |
isCacheInvalidationRequired()
Should we always invalidate the cache instead of recaching updated state |
boolean |
isIdentifierAssignedByInsert()
Are identifiers of this entity assigned known before the insert execution? Or, are they generated (in the database) by the insert execution. |
boolean |
isInherited()
Determine whether the entity is inherited one or more other entities. |
boolean |
isInstance(Object object,
EntityMode entityMode)
Is the given object an instance of this entity? |
boolean |
isInstrumented(EntityMode entityMode)
Has the class actually been bytecode instrumented? |
boolean |
isLazyPropertiesCacheable()
Should lazy properties of this entity be cached? |
boolean |
isMutable()
Determine whether instances of this entity are considered mutable. |
boolean |
isSelectBeforeUpdateRequired()
Is select snapshot before update enabled? |
boolean |
isSubclassEntityName(String entityName)
Determine whether the given name represents a subclass entity (or this entity itself) of the entity mapped by this persister. |
Boolean |
isTransient(Object object,
SessionImplementor session)
Is this a new transient instance? |
boolean |
isVersioned()
Determine whether optimistic locking by column is enabled for this entity. |
boolean |
isVersionPropertyGenerated()
Does this entity contain a version property that is defined to be database generated? |
Object |
load(Serializable id,
Object optionalObject,
LockMode lockMode,
SessionImplementor session)
Load an instance of the persistent class. |
Object |
load(Serializable id,
Object optionalObject,
LockOptions lockOptions,
SessionImplementor session)
Load an instance of the persistent class. |
void |
lock(Serializable id,
Object version,
Object object,
LockMode lockMode,
SessionImplementor session)
Do a version check (optional operation) |
void |
lock(Serializable id,
Object version,
Object object,
LockOptions lockOptions,
SessionImplementor session)
Do a version check (optional operation) |
void |
postInstantiate()
Finish the initialization of this object. |
void |
processInsertGeneratedProperties(Serializable id,
Object entity,
Object[] state,
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 PersistenceContext . |
void |
processUpdateGeneratedProperties(Serializable id,
Object entity,
Object[] state,
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 PersistenceContext . |
void |
resetIdentifier(Object entity,
Serializable currentId,
Object currentVersion,
EntityMode entityMode)
Deprecated. Use resetIdentifier(Object, Serializable, Object, SessionImplementor) instead |
void |
resetIdentifier(Object entity,
Serializable currentId,
Object currentVersion,
SessionImplementor session)
Set the identifier and version of the given instance back to its "unsaved" value. |
void |
setIdentifier(Object entity,
Serializable id,
EntityMode entityMode)
Deprecated. Use setIdentifier(Object, Serializable, SessionImplementor) instead. |
void |
setIdentifier(Object entity,
Serializable id,
SessionImplementor session)
Inject the identifier value into the given entity. |
void |
setPropertyValue(Object object,
int i,
Object value,
EntityMode entityMode)
Set the value of a particular property |
void |
setPropertyValues(Object object,
Object[] values,
EntityMode entityMode)
Set the given values to the mapped properties of the given object |
void |
update(Serializable id,
Object[] fields,
int[] dirtyFields,
boolean hasDirtyCollection,
Object[] oldFields,
Object oldVersion,
Object object,
Object rowId,
SessionImplementor session)
Update a persistent instance |
Methods inherited from interface org.hibernate.cache.OptimisticCacheSource |
---|
getVersionComparator |
Field Detail |
---|
static final String ENTITY_ID
Method Detail |
---|
void postInstantiate() throws MappingException
SessionFactory
lifecycle,
after all entity persisters have been instantiated.
MappingException
- Indicates an issue in the metadata.SessionFactoryImplementor getFactory()
String getRootEntityName()
String getEntityName()
EntityMetamodel getEntityMetamodel()
boolean isSubclassEntityName(String entityName)
entityName
- The entity name to be checked.
Serializable[] getPropertySpaces()
Serializable[] getQuerySpaces()
getPropertySpaces()
, except that here we include subclass
entity spaces.
boolean hasProxy()
boolean hasCollections()
boolean hasMutableProperties()
boolean hasSubselectLoadableCollections()
boolean hasCascades()
boolean isMutable()
boolean isInherited()
boolean isIdentifierAssignedByInsert()
Type getPropertyType(String propertyName) throws MappingException
propertyName
- The name of the property for which to retrieve
the type.
MappingException
- Typically indicates an unknown
property name.int[] findDirty(Object[] currentState, Object[] previousState, Object owner, SessionImplementor session)
currentState
- The current snapshotpreviousState
- The baseline snapshotowner
- The entity containing the statesession
- The originating session
int[] findModified(Object[] old, Object[] current, Object object, SessionImplementor session)
old
- The baseline snapshotcurrent
- The current snapshotobject
- The entity containing the statesession
- The originating session
boolean hasIdentifierProperty()
boolean canExtractIdOutOfEntity()
hasIdentifierProperty()
or
(2) the identifier is an embedded composite identifier; false otherwise.boolean isVersioned()
isVersioned
in interface OptimisticCacheSource
VersionType getVersionType()
isVersioned()
, then what is the type of the property
holding the locking value.
int getVersionProperty()
isVersioned()
, then what is the index of the property
holding the locking value.
boolean hasNaturalIdentifier()
int[] getNaturalIdentifierProperties()
hasNaturalIdentifier()
), which
properties make up the natural id.
Object[] getNaturalIdentifierSnapshot(Serializable id, SessionImplementor session)
id
- The identifier of the entity for which to retrieve the natural-id values.session
- The session from which the request originated.
IdentifierGenerator getIdentifierGenerator()
boolean hasLazyProperties()
Object load(Serializable id, Object optionalObject, LockMode lockMode, SessionImplementor session) throws HibernateException
HibernateException
Object load(Serializable id, Object optionalObject, LockOptions lockOptions, SessionImplementor session) throws HibernateException
HibernateException
void lock(Serializable id, Object version, Object object, LockMode lockMode, SessionImplementor session) throws HibernateException
HibernateException
void lock(Serializable id, Object version, Object object, LockOptions lockOptions, SessionImplementor session) throws HibernateException
HibernateException
void insert(Serializable id, Object[] fields, Object object, SessionImplementor session) throws HibernateException
HibernateException
Serializable insert(Object[] fields, Object object, SessionImplementor session) throws HibernateException
HibernateException
void delete(Serializable id, Object version, Object object, SessionImplementor session) throws HibernateException
HibernateException
void update(Serializable id, Object[] fields, int[] dirtyFields, boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object object, Object rowId, SessionImplementor session) throws HibernateException
HibernateException
Type[] getPropertyTypes()
String[] getPropertyNames()
boolean[] getPropertyInsertability()
ValueInclusion[] getPropertyInsertGenerationInclusions()
ValueInclusion[] getPropertyUpdateGenerationInclusions()
boolean[] getPropertyUpdateability()
boolean[] getPropertyCheckability()
boolean[] getPropertyNullability()
boolean[] getPropertyVersionability()
boolean[] getPropertyLaziness()
CascadeStyle[] getPropertyCascadeStyles()
Type getIdentifierType()
String getIdentifierPropertyName()
boolean isCacheInvalidationRequired()
boolean isLazyPropertiesCacheable()
boolean hasCache()
EntityRegionAccessStrategy getCacheAccessStrategy()
CacheEntryStructure getCacheEntryStructure()
ClassMetadata getClassMetadata()
boolean isBatchLoadable()
boolean isSelectBeforeUpdateRequired()
Object[] getDatabaseSnapshot(Serializable id, SessionImplementor session) throws HibernateException
HibernateException
Object getCurrentVersion(Serializable id, SessionImplementor session) throws HibernateException
HibernateException
Object forceVersionIncrement(Serializable id, Object currentVersion, SessionImplementor session) throws HibernateException
HibernateException
EntityMode guessEntityMode(Object object)
boolean isInstrumented(EntityMode entityMode)
boolean hasInsertGeneratedProperties()
boolean hasUpdateGeneratedProperties()
boolean isVersionPropertyGenerated()
void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session)
void afterReassociate(Object entity, SessionImplementor session)
Object createProxy(Serializable id, SessionImplementor session) throws HibernateException
HibernateException
Boolean isTransient(Object object, SessionImplementor session) throws HibernateException
HibernateException
Object[] getPropertyValuesToInsert(Object object, Map mergeMap, SessionImplementor session) throws HibernateException
HibernateException
void processInsertGeneratedProperties(Serializable id, Object entity, Object[] state, SessionImplementor session)
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.
id
- The entity's id value.entity
- The entity for which to get the state.state
- session
- The sessionvoid processUpdateGeneratedProperties(Serializable id, Object entity, Object[] state, SessionImplementor session)
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.
id
- The entity's id value.entity
- The entity for which to get the state.state
- session
- The sessionClass getMappedClass(EntityMode entityMode)
boolean implementsLifecycle(EntityMode entityMode)
boolean implementsValidatable(EntityMode entityMode)
Class getConcreteProxyClass(EntityMode entityMode)
void setPropertyValues(Object object, Object[] values, EntityMode entityMode) throws HibernateException
HibernateException
void setPropertyValue(Object object, int i, Object value, EntityMode entityMode) throws HibernateException
HibernateException
Object[] getPropertyValues(Object object, EntityMode entityMode) throws HibernateException
HibernateException
Object getPropertyValue(Object object, int i, EntityMode entityMode) throws HibernateException
HibernateException
Object getPropertyValue(Object object, String propertyName, EntityMode entityMode) throws HibernateException
HibernateException
Serializable getIdentifier(Object object, EntityMode entityMode) throws HibernateException
getIdentifier(Object,SessionImplementor)
instead
HibernateException
Serializable getIdentifier(Object entity, SessionImplementor session)
entity
- The entity for which to get the identifiersession
- The session from which the request originated
void setIdentifier(Object entity, Serializable id, EntityMode entityMode) throws HibernateException
setIdentifier(Object, Serializable, SessionImplementor)
instead.
entity
- The entity to inject with the identifier value.id
- The value to be injected as the identifier.entityMode
- The entity mode
HibernateException
void setIdentifier(Object entity, Serializable id, SessionImplementor session)
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 originatesObject getVersion(Object object, EntityMode entityMode) throws HibernateException
HibernateException
Object instantiate(Serializable id, EntityMode entityMode) throws HibernateException
instantiate(Serializable, SessionImplementor)
instead
HibernateException
Object instantiate(Serializable id, SessionImplementor session)
id
- The identifier value to use (may be null to represent no value)session
- The session from which the request originated.
boolean isInstance(Object object, EntityMode entityMode)
boolean hasUninitializedLazyProperties(Object object, EntityMode entityMode)
void resetIdentifier(Object entity, Serializable currentId, Object currentVersion, EntityMode entityMode)
resetIdentifier(Object, Serializable, Object, SessionImplementor)
instead
entity
- The entity instancecurrentId
- The currently assigned identifier value.currentVersion
- The currently assigned version value.entityMode
- The entity mode represented by the entity instance.void resetIdentifier(Object entity, Serializable currentId, Object currentVersion, SessionImplementor session)
entity
- The entity instancecurrentId
- The currently assigned identifier value.currentVersion
- The currently assigned version value.session
- The session from which the request originated.EntityPersister getSubclassEntityPersister(Object instance, SessionFactoryImplementor factory, EntityMode entityMode)
instance
- The entity instancefactory
- Reference to the SessionFactoryentityMode
- The entity mode represented by the entity instance.
HibernateException
- Indicates that instance was deemed to not be a subclass of the entity mapped by
this persister.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |