Author: steve.ebersole(a)jboss.com
Date: 2006-12-04 15:39:04 -0500 (Mon, 04 Dec 2006)
New Revision: 10916
Modified:
trunk/Hibernate3/src/org/hibernate/Session.java
Log:
javadocs
Modified: trunk/Hibernate3/src/org/hibernate/Session.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/Session.java 2006-12-04 20:38:55 UTC (rev 10915)
+++ trunk/Hibernate3/src/org/hibernate/Session.java 2006-12-04 20:39:04 UTC (rev 10916)
@@ -86,52 +86,71 @@
public Session getSession(EntityMode entityMode);
/**
- * Force the <tt>Session</tt> to flush. Must be called at the end of a
+ * Force this session to flush. Must be called at the end of a
* unit of work, before commiting the transaction and closing the
- * session (<tt>Transaction.commit()</tt> calls this method).
<i>Flushing</i>
- * is the process of synchronising the underlying persistent store with
- * persistable state held in memory.
+ * session (depending on {@link #setFlushMode flush-mode},
+ * {@link Transaction#commit()} calls this method).
+ * <p/>
+ * <i>Flushing</i> is the process of synchronizing the underlying
persistent
+ * store with persistable state held in memory.
*
- * @throws HibernateException
+ * @throws HibernateException Indicates problems flushing the session or
+ * talking to the database.
*/
public void flush() throws HibernateException;
/**
- * Set the flush mode. The flush mode determines at which points
- * Hibernate automatically flushes the session. For a readonly
- * session, it is reasonable to set the flush mode to
- * <tt>FlushMode.NEVER</tt> at the start of the session (in
+ * Set the flush mode for this session.
+ * <p/>
+ * The flush mode determines the points at which the session is flushed.
+ * <i>Flushing</i> is the process of synchronizing the underlying
persistent
+ * store with persistable state held in memory.
+ * <p/>
+ * For a logically "read only" session, it is reasonable to set the
session's
+ * flush mode to {@link FlushMode#MANUAL} at the start of the session (in
* order to achieve some extra performance).
*
+ * @param flushMode the new flush mode
* @see FlushMode
- * @param flushMode the FlushMode
*/
public void setFlushMode(FlushMode flushMode);
+
/**
- * Get the current flush mode.
+ * Get the current flush mode for this session.
*
- * @return FlushMode
+ * @return The flush mode
*/
public FlushMode getFlushMode();
-
+
/**
* Set the cache mode.
+ * <p/>
+ * Cache mode determines the manner in which this session can interact with
+ * the second level cache.
+ *
+ * @param cacheMode The new cache mode.
*/
public void setCacheMode(CacheMode cacheMode);
+
/**
* Get the current cache mode.
+ *
+ * @return The current cache mode.
*/
public CacheMode getCacheMode();
/**
- * Get the <tt>SessionFactory</tt> that created this instance.
+ * Get the session factory which created this session.
+ *
+ * @return The session factory.
* @see SessionFactory
+
*/
public SessionFactory getSessionFactory();
/**
* Get the JDBC connection of this Session.<br>
- * <br>
+ * <br>
* If the session is using aggressive collection release (as in a
* CMT environment), it is the application's responsibility to
* close the connection returned by this call. Otherwise, the
@@ -143,49 +162,53 @@
public Connection connection() throws HibernateException;
/**
- * End the <tt>Session</tt> by disconnecting from the JDBC connection and
- * cleaning up. It is not strictly necessary to <tt>close()</tt> the
- * <tt>Session</tt> but you must at least <tt>disconnect()</tt>
it.
+ * End the session by releasing the JDBC connection and cleaning up. It is
+ * not strictly necessary to close the session but you must at least
+ * {@link #disconnect()} it.
*
- * @return the connection provided by the application
- * or <tt>null</tt>
- * @throws HibernateException
+ * @return the connection provided by the application or null.
+ * @throws HibernateException Indicates problems cleaning up.
*/
public Connection close() throws HibernateException;
/**
- * Cancel execution of the current query. May be called from one thread
- * to stop execution of a query in another thread. Use with care!
+ * Cancel the execution of the current query.
+ * <p/>
+ * This is the sole method on session which may be safely called from
+ * another thread.
+ *
+ * @throws HibernateException There was a problem canceling the query
*/
public void cancelQuery() throws HibernateException;
/**
- * Check if the <tt>Session</tt> is still open.
+ * Check if the session is still open.
*
* @return boolean
*/
public boolean isOpen();
/**
- * Check if the <tt>Session</tt> is currently connected.
+ * Check if the session is currently connected.
*
* @return boolean
*/
public boolean isConnected();
-
+
/**
- * Does this <tt>Session</tt> contain any changes which must be
- * synchronized with the database? Would any SQL be executed if
+ * Does this session contain any changes which must be synchronized with
+ * the database? In other words, would any DML operations be executed if
* we flushed this session?
*
- * @return boolean
+ * @return True if the session contains pending changes; false otherwise.
+ * @throws HibernateException could not perform dirtying checking
*/
public boolean isDirty() throws HibernateException;
/**
- * Return the identifier of an entity instance cached by the
<tt>Session</tt>, or
- * throw an exception if the instance is transient or associated with a different
- * <tt>Session</tt>.
+ * Return the identifier value of the given entity as associated with this
+ * session. An exception is thrown if the given entity instance is transient
+ * or detached in relation to this session.
*
* @param object a persistent instance
* @return the identifier
@@ -193,6 +216,7 @@
* a different session
*/
public Serializable getIdentifier(Object object) throws HibernateException;
+
/**
* Check if this instance is associated with this <tt>Session</tt>.
*
@@ -200,6 +224,7 @@
* @return true if the given instance is associated with this
<tt>Session</tt>
*/
public boolean contains(Object object);
+
/**
* Remove this instance from the session cache. Changes to the instance will
* not be synchronized with the database. This operation cascades to associated
@@ -277,8 +302,8 @@
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
+ * 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
@@ -286,8 +311,8 @@
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
+ * 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
@@ -297,7 +322,7 @@
/**
* 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
+ * 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
@@ -309,7 +334,7 @@
/**
* 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
+ * 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
@@ -319,10 +344,11 @@
public Serializable save(String entityName, Object object) throws HibernateException;
/**
- * Either <tt>save()</tt> or <tt>update()</tt> the given
instance, depending upon the value of
- * its identifier property. By default the instance is always saved. This behaviour may
be
- * adjusted by specifying an <tt>unsaved-value</tt> attribute of the
identifier property
- * mapping. This operation cascades to associated instances if the association is mapped
+ * 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)
@@ -333,14 +359,15 @@
public void saveOrUpdate(Object object) throws HibernateException;
/**
- * Either <tt>save()</tt> or <tt>update()</tt> the given
instance, depending upon the value of
- * its identifier property. By default the instance is always saved. This behaviour may
be
- * adjusted by specifying an <tt>unsaved-value</tt> attribute of the
identifier property
- * mapping. This operation cascades to associated instances if the association is mapped
+ * 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(java.lang.Object)
- * @see Session#update(Object object)
+ * @see Session#save(String,Object)
+ * @see Session#update(String,Object)
* @param object a transient or detached instance containing new or updated state
* @throws HibernateException
*/
@@ -349,7 +376,7 @@
/**
* 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
+ * 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
@@ -360,7 +387,7 @@
/**
* 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
+ * 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
@@ -372,9 +399,9 @@
* 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
+ * 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.
@@ -383,14 +410,14 @@
* @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
+ * 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.
@@ -399,22 +426,22 @@
* @return an updated persistent instance
*/
public Object merge(String entityName, Object object) throws HibernateException;
-
+
/**
- * Make a transient instance persistent. This operation cascades to associated
+ * 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
+ * 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;
@@ -422,8 +449,8 @@
/**
* 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
+ * 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
@@ -448,7 +475,7 @@
* 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
+ * 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
@@ -461,7 +488,7 @@
* 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
+ * 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
@@ -519,7 +546,7 @@
* @see Transaction
*/
public Transaction beginTransaction() throws HibernateException;
-
+
/**
* Get the <tt>Transaction</tt> instance associated with this session.
* The class of the returned <tt>Transaction</tt> object is determined by
the
@@ -539,7 +566,7 @@
* @return Criteria
*/
public Criteria createCriteria(Class persistentClass);
-
+
/**
* Create a new <tt>Criteria</tt> instance, for the given entity class,
* or a superclass of an entity class, with the given alias.
@@ -548,7 +575,7 @@
* @return Criteria
*/
public Criteria createCriteria(Class persistentClass, String alias);
-
+
/**
* Create a new <tt>Criteria</tt> instance, for the given entity name.
*