站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

SessionImplementor (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.engine
Interface SessionImplementor

All Superinterfaces:
Serializable, Session
All Known Implementing Classes:
SessionImpl

public interface SessionImplementor
extends Session

Defines the internal contract between the Session and other parts of Hibernate such as implementors of Type or ClassPersister.

Author:
Gavin King
See Also:
the interface to the application, the actual implementation

Method Summary
 void addArrayHolder(ArrayHolder holder)
          Register a PersistentCollection object for an array
 void addNonExist(Key key)
           
 void addUninitializedEntity(Key key, Object object, LockMode lockMode)
          Add an uninitialized instance of an entity class, as a placeholder to ensure object identity.
 void afterLoad()
           
 void afterTransactionCompletion(boolean successful)
          Notify the session that the transaction completed, so we no longer own the old locks.
 void beforeLoad()
           
 Object copy(Object object, Map copiedAlready)
           
 void endLoadingCollections(CollectionPersister persister, Object resultSetId)
           
 List filter(Object collection, String filter, QueryParameters queryParameters)
          Execute a filter
 List find(String query, QueryParameters queryParameters)
          Execute a find() query
 List findBySQL(String sqlQuery, String[] aliases, Class[] classes, QueryParameters queryParameters, Collection querySpaces)
          Execute an SQL Query
 ArrayHolder getArrayHolder(Object array)
          Get the PersistentCollection object for an array
 Batcher getBatcher()
          Get the prepared statement Batcher for this session
 Serializable[] getClassBatch(Class clazz, Serializable id, int batchSize)
          Get a batch of unloaded identifiers for this class
 Object getCollection(String role, Serializable id, Object owner)
           
 Serializable[] getCollectionBatch(CollectionPersister collectionPersister, Serializable id, int batchSize)
          Get a batch of uninitialized collection keys for this role
 Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister)
           
 Object getEntity(Key key)
          Get the entity instance associated with the given Key
 Serializable getEntityIdentifier(Object obj)
          Return the identifier of the persistent object, or null if transient
 Serializable getEntityIdentifierIfNotUnsaved(Object object)
          Return the identifier of the persistent or transient object, or throw an exception if the instance is "unsaved"
 SessionFactoryImplementor getFactory()
          Get the creating SessionFactoryImplementor
 Serializable getLoadedCollectionKey(PersistentCollection collection)
          Get the pre-flush identifier of the collection
 PersistentCollection getLoadingCollection(CollectionPersister persister, Serializable id, Object resultSetId)
           
 LockMode getLockMode(Object object)
          Get the lock mode of the entity
 Collection getOrphans(PersistentCollection coll)
          Get the collection orphans (entities which were removed from the collection)
 ClassPersister getPersister(Object object)
          Get the ClassPersister for an object
 Serializable getSnapshot(PersistentCollection collection)
          Get the snapshot of the pre-flush collection state
 long getTimestamp()
          System time before the start of the transaction
 Object getVersion(Object entity)
          Get the current versioon of the entity
 Object immediateLoad(Class persistentClass, Serializable id)
          Load an instance immediately.
 void initializeCollection(PersistentCollection collection, boolean writing)
          Initialize the collection (if not already initialized)
 void initializeEntity(Object object)
          Perform the second step of 2-phase load.
 void initializeNonLazyCollections()
           
 Object instantiate(Class clazz, Serializable id)
          Instantiate the entity class, initializing with the given identifier
 Object internalLoad(Class persistentClass, Serializable id)
          Load an instance without checking if it was deleted.
 Object internalLoadOneToOne(Class persistentClass, Serializable id)
          Load an instance without checking if it was deleted.
 boolean isInverseCollection(PersistentCollection collection)
          Is this the "inverse" end of a bidirectional association?
 boolean isSaved(Object object)
          Was this object already saved to the database?
 Iterator iterate(String query, QueryParameters queryParameters)
          Execute an iterate() query
 Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters)
          Iterate a filter
 Object loadByUniqueKey(Class persistentClass, String uniqueKeyPropertyName, Serializable id)
          Load an instance by a unique key that is not the primary key.
 void postDelete(Object object)
          After actually deleting a row, record the fact that the instance no longer exists on the database (needed for identity-column key generation)
 void postHydrate(ClassPersister persister, Serializable id, Object[] values, Object object, LockMode lockMode)
          Register the "hydrated" state of an entity instance, after the first step of 2-phase loading
 void postInsert(Object object)
          After actually inserting a row, record the fact that the instance exists on the database (needed for identity-column key generation)
 void postUpdate(Object object, Object[] updatedState, Object nextVersion)
          After actually updating a row, record the fact that the database state has been updated
 Object proxyFor(ClassPersister persister, Key key, Object impl)
          Return the existing proxy associated with the given Key, or the second argument (the entity associated with the key) if no proxy exists.
 Object proxyFor(Object impl)
          Return the existing proxy associated with the given Key, or the second argument (the entity associated with the key) if no proxy exists.
 void scheduleBatchLoad(Class clazz, Serializable id)
          Register the entity as batch loadable, if enabled
 ScrollableResults scroll(String query, QueryParameters queryParameters)
          Execute a scroll() query
 void setLockMode(Object entity, LockMode lockMode)
          Set the lock mode of the entity to the given lock mode
 
Methods inherited from interface net.sf.hibernate.Session
beginTransaction, cancelQuery, clear, close, connection, contains, createCriteria, createFilter, createQuery, createSQLQuery, createSQLQuery, delete, delete, delete, delete, disconnect, evict, filter, filter, filter, find, find, find, flush, get, get, getCurrentLockMode, getFlushMode, getIdentifier, getNamedQuery, getSessionFactory, isConnected, isDirty, isOpen, iterate, iterate, iterate, load, load, load, lock, reconnect, reconnect, refresh, refresh, replicate, save, save, saveOrUpdate, saveOrUpdateCopy, saveOrUpdateCopy, setFlushMode, update, update
 

Method Detail

getLoadedCollectionKey

public Serializable getLoadedCollectionKey(PersistentCollection collection)
Get the pre-flush identifier of the collection


getSnapshot

public Serializable getSnapshot(PersistentCollection collection)
Get the snapshot of the pre-flush collection state


getArrayHolder

public ArrayHolder getArrayHolder(Object array)
Get the PersistentCollection object for an array


addArrayHolder

public void addArrayHolder(ArrayHolder holder)
Register a PersistentCollection object for an array


initializeCollection

public void initializeCollection(PersistentCollection collection,
                                 boolean writing)
                          throws HibernateException
Initialize the collection (if not already initialized)

Throws:
HibernateException

isInverseCollection

public boolean isInverseCollection(PersistentCollection collection)
Is this the "inverse" end of a bidirectional association?


getLoadingCollection

public PersistentCollection getLoadingCollection(CollectionPersister persister,
                                                 Serializable id,
                                                 Object resultSetId)
                                          throws HibernateException
Throws:
HibernateException

endLoadingCollections

public void endLoadingCollections(CollectionPersister persister,
                                  Object resultSetId)
                           throws HibernateException
Throws:
HibernateException

afterLoad

public void afterLoad()

beforeLoad

public void beforeLoad()

initializeNonLazyCollections

public void initializeNonLazyCollections()
                                  throws HibernateException
Throws:
HibernateException

getCollection

public Object getCollection(String role,
                            Serializable id,
                            Object owner)
                     throws HibernateException
Throws:
HibernateException

internalLoad

public Object internalLoad(Class persistentClass,
                           Serializable id)
                    throws HibernateException
Load an instance without checking if it was deleted. If it does not exist, throw an exception. This method may create a new proxy or return an existing proxy.

Throws:
HibernateException

internalLoadOneToOne

public Object internalLoadOneToOne(Class persistentClass,
                                   Serializable id)
                            throws HibernateException
Load an instance without checking if it was deleted. If it does not exist, return null. Do not create a proxy (but do return any existing proxy).

Throws:
HibernateException

immediateLoad

public Object immediateLoad(Class persistentClass,
                            Serializable id)
                     throws HibernateException
Load an instance immediately. Do not return a proxy.

Throws:
HibernateException

loadByUniqueKey

public Object loadByUniqueKey(Class persistentClass,
                              String uniqueKeyPropertyName,
                              Serializable id)
                       throws HibernateException
Load an instance by a unique key that is not the primary key.

Throws:
HibernateException

getTimestamp

public long getTimestamp()
System time before the start of the transaction


getFactory

public SessionFactoryImplementor getFactory()
Get the creating SessionFactoryImplementor


getBatcher

public Batcher getBatcher()
Get the prepared statement Batcher for this session


postInsert

public void postInsert(Object object)
After actually inserting a row, record the fact that the instance exists on the database (needed for identity-column key generation)


postDelete

public void postDelete(Object object)
After actually deleting a row, record the fact that the instance no longer exists on the database (needed for identity-column key generation)


postUpdate

public void postUpdate(Object object,
                       Object[] updatedState,
                       Object nextVersion)
                throws HibernateException
After actually updating a row, record the fact that the database state has been updated

Throws:
HibernateException

find

public List find(String query,
                 QueryParameters queryParameters)
          throws HibernateException
Execute a find() query

Throws:
HibernateException

iterate

public Iterator iterate(String query,
                        QueryParameters queryParameters)
                 throws HibernateException
Execute an iterate() query

Throws:
HibernateException

scroll

public ScrollableResults scroll(String query,
                                QueryParameters queryParameters)
                         throws HibernateException
Execute a scroll() query

Throws:
HibernateException

filter

public List filter(Object collection,
                   String filter,
                   QueryParameters queryParameters)
            throws HibernateException
Execute a filter

Throws:
HibernateException

iterateFilter

public Iterator iterateFilter(Object collection,
                              String filter,
                              QueryParameters queryParameters)
                       throws HibernateException
Iterate a filter

Throws:
HibernateException

getPersister

public ClassPersister getPersister(Object object)
                            throws MappingException
Get the ClassPersister for an object

Throws:
MappingException

addUninitializedEntity

public void addUninitializedEntity(Key key,
                                   Object object,
                                   LockMode lockMode)
Add an uninitialized instance of an entity class, as a placeholder to ensure object identity. Must be called before postHydrate().


postHydrate

public void postHydrate(ClassPersister persister,
                        Serializable id,
                        Object[] values,
                        Object object,
                        LockMode lockMode)
                 throws HibernateException
Register the "hydrated" state of an entity instance, after the first step of 2-phase loading

Throws:
HibernateException

initializeEntity

public void initializeEntity(Object object)
                      throws HibernateException
Perform the second step of 2-phase load. Fully initialize the entity instance.

Throws:
HibernateException

getEntity

public Object getEntity(Key key)
Get the entity instance associated with the given Key


proxyFor

public Object proxyFor(ClassPersister persister,
                       Key key,
                       Object impl)
                throws HibernateException
Return the existing proxy associated with the given Key, or the second argument (the entity associated with the key) if no proxy exists.

Throws:
HibernateException

proxyFor

public Object proxyFor(Object impl)
                throws HibernateException
Return the existing proxy associated with the given Key, or the second argument (the entity associated with the key) if no proxy exists. (slower than the form above)

Throws:
HibernateException

afterTransactionCompletion

public void afterTransactionCompletion(boolean successful)
Notify the session that the transaction completed, so we no longer own the old locks. (Also we should release cache softlocks.) May be called multiple times during the transaction completion process.


getEntityIdentifier

public Serializable getEntityIdentifier(Object obj)
Return the identifier of the persistent object, or null if transient


getEntityIdentifierIfNotUnsaved

public Serializable getEntityIdentifierIfNotUnsaved(Object object)
                                             throws HibernateException
Return the identifier of the persistent or transient object, or throw an exception if the instance is "unsaved"

Throws:
HibernateException

isSaved

public boolean isSaved(Object object)
                throws HibernateException
Was this object already saved to the database?

Throws:
HibernateException

instantiate

public Object instantiate(Class clazz,
                          Serializable id)
                   throws HibernateException
Instantiate the entity class, initializing with the given identifier

Throws:
HibernateException

setLockMode

public void setLockMode(Object entity,
                        LockMode lockMode)
Set the lock mode of the entity to the given lock mode


getVersion

public Object getVersion(Object entity)
Get the current versioon of the entity


getLockMode

public LockMode getLockMode(Object object)
Get the lock mode of the entity


getOrphans

public Collection getOrphans(PersistentCollection coll)
                      throws HibernateException
Get the collection orphans (entities which were removed from the collection)

Throws:
HibernateException

getCollectionBatch

public Serializable[] getCollectionBatch(CollectionPersister collectionPersister,
                                         Serializable id,
                                         int batchSize)
Get a batch of uninitialized collection keys for this role

Parameters:
collectionPersister - the collection role
id - a key that must be included
batchSize - the maximum number of keys to return
Returns:
an array of collection keys, of length batchSize (padded with nulls)

getClassBatch

public Serializable[] getClassBatch(Class clazz,
                                    Serializable id,
                                    int batchSize)
Get a batch of unloaded identifiers for this class

Parameters:
clazz - the persistent class
id - an identifier that must be included
batchSize - the maximum number of keys to return
Returns:
an array of identifiers, of length batchSize (padded with nulls)

scheduleBatchLoad

public void scheduleBatchLoad(Class clazz,
                              Serializable id)
                       throws MappingException
Register the entity as batch loadable, if enabled

Throws:
MappingException

findBySQL

public List findBySQL(String sqlQuery,
                      String[] aliases,
                      Class[] classes,
                      QueryParameters queryParameters,
                      Collection querySpaces)
               throws HibernateException
Execute an SQL Query

Throws:
HibernateException

addNonExist

public void addNonExist(Key key)

copy

public Object copy(Object object,
                   Map copiedAlready)
            throws HibernateException
Throws:
HibernateException

getCollectionOwner

public Object getCollectionOwner(Serializable key,
                                 CollectionPersister collectionPersister)
                          throws MappingException
Throws:
MappingException