session.java
来自「hibernate-distribution-3.3.1.GA-dist.zip」· Java 代码 · 共 817 行 · 第 1/3 页
JAVA
817 行
public Object load(Class theClass, Serializable id, LockMode lockMode) throws HibernateException; /** * Return the persistent instance of the given entity class with the given identifier, * obtaining the specified lock mode, assuming the instance exists. * * @param entityName a persistent class * @param id a valid identifier of an existing persistent instance of the class * @param lockMode the lock level * @return the persistent instance or proxy * @throws HibernateException */ public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException; /** * Return the persistent instance of the given entity class with the given identifier, * assuming that the instance exists. This method might return a proxied instance that * is initialized on-demand, when a non-identifier method is accessed. * <br><br> * You should not use this method to determine if an instance exists (use <tt>get()</tt> * instead). Use this only to retrieve an instance that you assume exists, where non-existence * would be an actual error. * * @param theClass a persistent class * @param id a valid identifier of an existing persistent instance of the class * @return the persistent instance or proxy * @throws HibernateException */ public Object load(Class theClass, Serializable id) throws HibernateException; /** * Return the persistent instance of the given entity class with the given identifier, * assuming that the instance exists. This method might return a proxied instance that * is initialized on-demand, when a non-identifier method is accessed. * <br><br> * You should not use this method to determine if an instance exists (use <tt>get()</tt> * instead). Use this only to retrieve an instance that you assume exists, where non-existence * would be an actual error. * * @param entityName a persistent class * @param id a valid identifier of an existing persistent instance of the class * @return the persistent instance or proxy * @throws HibernateException */ public Object load(String entityName, Serializable id) throws HibernateException; /** * Read the persistent state associated with the given identifier into the given transient * instance. * * @param object an "empty" instance of the persistent class * @param id a valid identifier of an existing persistent instance of the class * @throws HibernateException */ public void load(Object object, Serializable id) throws HibernateException; /** * Persist the state of the given detached instance, reusing the current * identifier value. This operation cascades to associated instances if * the association is mapped with <tt>cascade="replicate"</tt>. * * @param object a detached instance of a persistent class */ public void replicate(Object object, ReplicationMode replicationMode) throws HibernateException; /** * Persist the state of the given detached instance, reusing the current * identifier value. This operation cascades to associated instances if * the association is mapped with <tt>cascade="replicate"</tt>. * * @param object a detached instance of a persistent class */ public void replicate(String entityName, Object object, ReplicationMode replicationMode) throws HibernateException; /** * Persist the given transient instance, first assigning a generated identifier. (Or * using the current value of the identifier property if the <tt>assigned</tt> * generator is used.) This operation cascades to associated instances if the * association is mapped with <tt>cascade="save-update"</tt>. * * @param object a transient instance of a persistent class * @return the generated identifier * @throws HibernateException */ public Serializable save(Object object) throws HibernateException; /** * Persist the given transient instance, first assigning a generated identifier. (Or * using the current value of the identifier property if the <tt>assigned</tt> * generator is used.) This operation cascades to associated instances if the * association is mapped with <tt>cascade="save-update"</tt>. * * @param object a transient instance of a persistent class * @return the generated identifier * @throws HibernateException */ public Serializable save(String entityName, Object object) throws HibernateException; /** * Either {@link #save(Object)} or {@link #update(Object)} the given * instance, depending upon resolution of the unsaved-value checks (see the * manual for discussion of unsaved-value checking). * <p/> * This operation cascades to associated instances if the association is mapped * with <tt>cascade="save-update"</tt>. * * @see Session#save(java.lang.Object) * @see Session#update(Object object) * @param object a transient or detached instance containing new or updated state * @throws HibernateException */ public void saveOrUpdate(Object object) throws HibernateException; /** * Either {@link #save(String, Object)} or {@link #update(String, Object)} * the given instance, depending upon resolution of the unsaved-value checks * (see the manual for discussion of unsaved-value checking). * <p/> * This operation cascades to associated instances if the association is mapped * with <tt>cascade="save-update"</tt>. * * @see Session#save(String,Object) * @see Session#update(String,Object) * @param object a transient or detached instance containing new or updated state * @throws HibernateException */ public void saveOrUpdate(String entityName, Object object) throws HibernateException; /** * Update the persistent instance with the identifier of the given detached * instance. If there is a persistent instance with the same identifier, * an exception is thrown. This operation cascades to associated instances * if the association is mapped with <tt>cascade="save-update"</tt>. * * @param object a detached instance containing updated state * @throws HibernateException */ public void update(Object object) throws HibernateException; /** * Update the persistent instance with the identifier of the given detached * instance. If there is a persistent instance with the same identifier, * an exception is thrown. This operation cascades to associated instances * if the association is mapped with <tt>cascade="save-update"</tt>. * * @param object a detached instance containing updated state * @throws HibernateException */ public void update(String entityName, Object object) throws HibernateException; /** * Copy the state of the given object onto the persistent object with the same * identifier. If there is no persistent instance currently associated with * the session, it will be loaded. Return the persistent instance. If the * given instance is unsaved, save a copy of and return it as a newly persistent * instance. The given instance does not become associated with the session. * This operation cascades to associated instances if the association is mapped * with <tt>cascade="merge"</tt>.<br> * <br> * The semantics of this method are defined by JSR-220. * * @param object a detached instance with state to be copied * @return an updated persistent instance */ public Object merge(Object object) throws HibernateException; /** * Copy the state of the given object onto the persistent object with the same * identifier. If there is no persistent instance currently associated with * the session, it will be loaded. Return the persistent instance. If the * given instance is unsaved, save a copy of and return it as a newly persistent * instance. The given instance does not become associated with the session. * This operation cascades to associated instances if the association is mapped * with <tt>cascade="merge"</tt>.<br> * <br> * The semantics of this method are defined by JSR-220. * * @param object a detached instance with state to be copied * @return an updated persistent instance */ public Object merge(String entityName, Object object) throws HibernateException; /** * Make a transient instance persistent. This operation cascades to associated * instances if the association is mapped with <tt>cascade="persist"</tt>.<br> * <br> * The semantics of this method are defined by JSR-220. * * @param object a transient instance to be made persistent */ public void persist(Object object) throws HibernateException; /** * Make a transient instance persistent. This operation cascades to associated * instances if the association is mapped with <tt>cascade="persist"</tt>.<br> * <br> * The semantics of this method are defined by JSR-220. * * @param object a transient instance to be made persistent */ public void persist(String entityName, Object object) throws HibernateException; /** * Remove a persistent instance from the datastore. The argument may be * an instance associated with the receiving <tt>Session</tt> or a transient * instance with an identifier associated with existing persistent state. * This operation cascades to associated instances if the association is mapped * with <tt>cascade="delete"</tt>. * * @param object the instance to be removed * @throws HibernateException */ public void delete(Object object) throws HibernateException; /** * Remove a persistent instance from the datastore. The <b>object</b> argument may be * an instance associated with the receiving <tt>Session</tt> or a transient * instance with an identifier associated with existing persistent state. * This operation cascades to associated instances if the association is mapped * with <tt>cascade="delete"</tt>. * * @param entityName The entity name for the instance to be removed. * @param object the instance to be removed * @throws HibernateException */ public void delete(String entityName, Object object) throws HibernateException; /** * Obtain the specified lock level upon the given object. This may be used to * perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic * lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated * instances if the association is mapped with <tt>cascade="lock"</tt>. * * @param object a persistent or transient instance * @param lockMode the lock level * @throws HibernateException */ public void lock(Object object, LockMode lockMode) throws HibernateException; /** * Obtain the specified lock level upon the given object. This may be used to * perform a version check (<tt>LockMode.READ</tt>), to upgrade to a pessimistic * lock (<tt>LockMode.UPGRADE</tt>), or to simply reassociate a transient instance * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated * instances if the association is mapped with <tt>cascade="lock"</tt>. * * @param object a persistent or transient instance * @param lockMode the lock level * @throws HibernateException */ public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException; /** * Re-read the state of the given instance from the underlying database. It is * inadvisable to use this to implement long-running sessions that span many * business tasks. This method is, however, useful in certain special circumstances. * For example * <ul> * <li>where a database trigger alters the object state upon insert or update * <li>after executing direct SQL (eg. a mass update) in the same session * <li>after inserting a <tt>Blob</tt> or <tt>Clob</tt> * </ul> * * @param object a persistent or detached instance * @throws HibernateException */ public void refresh(Object object) throws HibernateException; /** * Re-read the state of the given instance from the underlying database, with * the given <tt>LockMode</tt>. It is inadvisable to use this to implement * long-running sessions that span many business tasks. This method is, however, * useful in certain special circumstances.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?