Save This Page
Home » Hibernate-3.3.2.GA » org.hibernate » persister » entity » [javadoc | source]
org.hibernate.persister.entity
public interface: EntityPersister [javadoc | source]

All Implemented Interfaces:
    OptimisticCacheSource

All Known Implementing Classes:
    SQLLoadable, Lockable, UniqueKeyLoadable, Queryable, SingleTableEntityPersister, PostInsertIdentityPersister, UnionSubclassEntityPersister, AbstractEntityPersister, OuterJoinLoadable, JoinedSubclassEntityPersister, Loadable, BasicEntityPersister

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: org.hibernate.mapping.PersistentClass , org.hibernate.engine.SessionFactoryImplementor

Field Summary
public static final  String ENTITY_ID    The property name of the "special" identifier property in HQL 
Method from org.hibernate.persister.entity.EntityPersister Summary:
afterInitialize,   afterReassociate,   canExtractIdOutOfEntity,   createProxy,   delete,   findDirty,   findModified,   forceVersionIncrement,   getCacheAccessStrategy,   getCacheEntryStructure,   getClassMetadata,   getConcreteProxyClass,   getCurrentVersion,   getDatabaseSnapshot,   getEntityMetamodel,   getEntityName,   getFactory,   getIdentifier,   getIdentifierGenerator,   getIdentifierPropertyName,   getIdentifierType,   getMappedClass,   getNaturalIdentifierProperties,   getNaturalIdentifierSnapshot,   getPropertyCascadeStyles,   getPropertyCheckability,   getPropertyInsertGenerationInclusions,   getPropertyInsertability,   getPropertyLaziness,   getPropertyNames,   getPropertyNullability,   getPropertySpaces,   getPropertyType,   getPropertyTypes,   getPropertyUpdateGenerationInclusions,   getPropertyUpdateability,   getPropertyValue,   getPropertyValue,   getPropertyValues,   getPropertyValuesToInsert,   getPropertyVersionability,   getQuerySpaces,   getRootEntityName,   getSubclassEntityPersister,   getVersion,   getVersionProperty,   getVersionType,   guessEntityMode,   hasCache,   hasCascades,   hasCollections,   hasIdentifierProperty,   hasInsertGeneratedProperties,   hasLazyProperties,   hasMutableProperties,   hasNaturalIdentifier,   hasProxy,   hasSubselectLoadableCollections,   hasUninitializedLazyProperties,   hasUpdateGeneratedProperties,   implementsLifecycle,   implementsValidatable,   insert,   insert,   instantiate,   isBatchLoadable,   isCacheInvalidationRequired,   isIdentifierAssignedByInsert,   isInherited,   isInstance,   isInstrumented,   isLazyPropertiesCacheable,   isMutable,   isSelectBeforeUpdateRequired,   isSubclassEntityName,   isTransient,   isVersionPropertyGenerated,   isVersioned,   load,   lock,   postInstantiate,   processInsertGeneratedProperties,   processUpdateGeneratedProperties,   resetIdentifier,   setIdentifier,   setPropertyValue,   setPropertyValues,   update
Method from org.hibernate.persister.entity.EntityPersister Detail:
 public  void afterInitialize(Object entity,
    boolean lazyPropertiesAreUnfetched,
    SessionImplementor session)
    Called just after the entities properties have been initialized
 public  void afterReassociate(Object entity,
    SessionImplementor session)
    Called just after the entity has been reassociated with the session
 public boolean canExtractIdOutOfEntity()
    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.

 public Object createProxy(Serializable id,
    SessionImplementor session) throws HibernateException
    Create a new proxy instance
 public  void delete(Serializable id,
    Object version,
    Object object,
    SessionImplementor session) throws HibernateException
    Delete a persistent instance
 public int[] findDirty(Object[] currentState,
    Object[] previousState,
    Object owner,
    SessionImplementor session)
    Compare the two snapshots to determine if they represent dirty state.
 public int[] findModified(Object[] old,
    Object[] current,
    Object object,
    SessionImplementor session)
    Compare the two snapshots to determine if they represent modified state.
 public Object forceVersionIncrement(Serializable id,
    Object currentVersion,
    SessionImplementor session) throws HibernateException
 public EntityRegionAccessStrategy getCacheAccessStrategy()
    Get the cache (optional operation)
 public CacheEntryStructure getCacheEntryStructure()
    Get the cache structure
 public ClassMetadata getClassMetadata()
    Get the user-visible metadata for the class (optional operation)
 public Class getConcreteProxyClass(EntityMode entityMode)
    Get the proxy interface that instances of this concrete class will be cast to (optional operation).
 public Object getCurrentVersion(Serializable id,
    SessionImplementor session) throws HibernateException
    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 Object[] getDatabaseSnapshot(Serializable id,
    SessionImplementor session) throws HibernateException
    Get the current database state of the object, in a "hydrated" form, without resolving identifiers
 public EntityMetamodel getEntityMetamodel()
    Retrieve the underlying entity metamodel instance...
 public String getEntityName()
    The entity name which this persister maps.
 public SessionFactoryImplementor getFactory()
    Return the SessionFactory to which this persister "belongs".
 public Serializable getIdentifier(Object object,
    EntityMode entityMode) throws HibernateException
    Get the identifier of an instance (throw an exception if no identifier property)
 public IdentifierGenerator getIdentifierGenerator()
    Determine which identifier generation strategy is used for this entity.
 public String getIdentifierPropertyName()
    Get the name of the identifier property (or return null) - need not return the name of an actual Java property
 public Type getIdentifierType()
    Get the identifier type
 public Class getMappedClass(EntityMode entityMode)
    The persistent class, or null
 public int[] getNaturalIdentifierProperties()
 public Object[] getNaturalIdentifierSnapshot(Serializable id,
    SessionImplementor session)
    Retrieve the current state of the natural-id properties from the database.
 public 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 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 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 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).

 public Type getPropertyType(String propertyName) throws MappingException
    Get the type of a particular property by name.
 public Type[] getPropertyTypes()
    Get the Hibernate types of the class properties
 public 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 Object getPropertyValue(Object object,
    int i,
    EntityMode entityMode) throws HibernateException
    Get the value of a particular property
 public Object getPropertyValue(Object object,
    String propertyName,
    EntityMode entityMode) throws HibernateException
    Get the value of a particular property
 public Object[] getPropertyValues(Object object,
    EntityMode entityMode) throws HibernateException
    Return the (loaded) values of the mapped properties of the object (not including backrefs)
 public Object[] getPropertyValuesToInsert(Object object,
    Map mergeMap,
    SessionImplementor session) throws HibernateException
    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 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 #getPropertySpaces() , except that here we include subclass entity spaces.

 public String getRootEntityName()
    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.
 public 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. However, we still need to account for possible subclassing and potentially re-route to the more appropriate persister.

    For example, a request names Animal as the entity-name which gets resolved to this persister. But the actual instance is really an instance of Cat which is a subclass of Animal. So, here the Animal persister is being asked to return the persister specific to Cat.

    It is also possible that the instance is actually an Animal instance in the above example in which case we would retrn this from this method.

 public Object getVersion(Object object,
    EntityMode entityMode) throws HibernateException
    Get the version number (or timestamp) from the object's version property (or return null if not versioned)
 public int getVersionProperty()
    If #isVersioned() , then what is the index of the property holding the locking value.
 public VersionType getVersionType()
    If #isVersioned() , then what is the type of the property holding the locking value.
 public EntityMode guessEntityMode(Object object)
    Try to discover the entity mode from the entity instance
 public boolean hasCache()
    Does this class have a cache.
 public boolean hasCascades()
    Determine whether this entity has any non-none cascading.
 public boolean hasCollections()
    Determine whether this entity contains references to persistent collections.
 public boolean hasIdentifierProperty()
    Determine whether the entity has a particular property holding the identifier value.
 public boolean hasInsertGeneratedProperties()
    Does this entity define any properties as being database generated on insert?
 public boolean hasLazyProperties()
    Determine whether this entity defines any lazy properties (ala bytecode instrumentation).
 public boolean hasMutableProperties()
    Determine whether any properties of this entity are considered mutable.
 public boolean hasNaturalIdentifier()
    Determine whether this entity defines a natural identifier.
 public boolean hasProxy()
    Determine whether this entity supports dynamic proxies.
 public boolean hasSubselectLoadableCollections()
    Determine whether this entity contains references to persistent collections which are fetchable by subselect?
 public boolean hasUninitializedLazyProperties(Object object,
    EntityMode entityMode)
    Does the given instance have any uninitialized lazy properties?
 public boolean hasUpdateGeneratedProperties()
    Does this entity define any properties as being database generated on update?
 public boolean implementsLifecycle(EntityMode entityMode)
    Does the class implement the Lifecycle interface.
 public boolean implementsValidatable(EntityMode entityMode)
    Does the class implement the Validatable interface.
 public Serializable insert(Object[] fields,
    Object object,
    SessionImplementor session) throws HibernateException
    Persist an instance, using a natively generated identifier (optional operation)
 public  void insert(Serializable id,
    Object[] fields,
    Object object,
    SessionImplementor session) throws HibernateException
    Persist an instance
 public Object instantiate(Serializable id,
    EntityMode entityMode) throws HibernateException
    Create a class instance initialized with the given identifier
 public boolean isBatchLoadable()
    Is batch loading enabled?
 public boolean isCacheInvalidationRequired()
    Should we always invalidate the cache instead of recaching updated state
 public boolean isIdentifierAssignedByInsert()
    Are identifiers of this entity assigned known before the insert execution? Or, are they generated (in the database) by the insert execution.
 public boolean isInherited()
    Determine whether the entity is inherited one or more other entities. In other words, is this entity a subclass of other entities.
 public boolean isInstance(Object object,
    EntityMode entityMode)
    Is the given object an instance of this entity?
 public boolean isInstrumented(EntityMode entityMode)
    Has the class actually been bytecode instrumented?
 public boolean isLazyPropertiesCacheable()
    Should lazy properties of this entity be cached?
 public boolean isMutable()
    Determine whether instances of this entity are considered mutable.
 public boolean isSelectBeforeUpdateRequired()
    Is select snapshot before update enabled?
 public boolean isSubclassEntityName(String entityName)
    Determine whether the given name represents a subclass entity (or this entity itself) of the entity mapped by this persister.
 public Boolean isTransient(Object object,
    SessionImplementor session) throws HibernateException
    Is this a new transient instance?
 public boolean isVersionPropertyGenerated()
    Does this entity contain a version property that is defined to be database generated?
 public boolean isVersioned()
    Determine whether optimistic locking by column is enabled for this entity.
 public Object load(Serializable id,
    Object optionalObject,
    LockMode lockMode,
    SessionImplementor session) throws HibernateException
    Load an instance of the persistent class.
 public  void lock(Serializable id,
    Object version,
    Object object,
    LockMode lockMode,
    SessionImplementor session) throws HibernateException
    Do a version check (optional operation)
 public  void postInstantiate() throws MappingException
    Finish the initialization of this object.

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

 public  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 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.

 public  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 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.

 public  void resetIdentifier(Object entity,
    Serializable currentId,
    Object currentVersion,
    EntityMode entityMode)
    Set the identifier and version of the given instance back to its "unsaved" value.
 public  void setIdentifier(Object object,
    Serializable id,
    EntityMode entityMode) throws HibernateException
    Set the identifier of an instance (or do nothing if no identifier property)
 public  void setPropertyValue(Object object,
    int i,
    Object value,
    EntityMode entityMode) throws HibernateException
    Set the value of a particular property
 public  void setPropertyValues(Object object,
    Object[] values,
    EntityMode entityMode) throws HibernateException
    Set the given values to the mapped properties of the given object
 public  void update(Serializable id,
    Object[] fields,
    int[] dirtyFields,
    boolean hasDirtyCollection,
    Object[] oldFields,
    Object oldVersion,
    Object object,
    Object rowId,
    SessionImplementor session) throws HibernateException
    Update a persistent instance