org.hibernate
Interface Session

public interface Session
extends Serializable
The main runtime interface between a Java application and Hibernate. This is the central API class abstracting the notion of a persistence service.

The lifecycle of a Session is bounded by the beginning and end of a logical transaction. (Long transactions might span several database transactions.)

The main function of the Session is to offer create, read and delete operations for instances of mapped entity classes. Instances may exist in one of three states:

transient: never persistent, not associated with any Session
persistent: associated with a unique Session
detached: previously persistent, not associated with any Session

Transient instances may be made persistent by calling save(), persist() or saveOrUpdate(). Persistent instances may be made transient by calling delete(). Any instance returned by a get() or load() method is persistent. Detached instances may be made persistent by calling update(), saveOrUpdate(), lock() or replicate(). The state of a transient or detached instance may also be made persistent as a new persistent instance by calling merge().

save() and persist() result in an SQL INSERT, delete() in an SQL DELETE and update() or merge() in an SQL UPDATE. Changes to persistent instances are detected at flush time and also result in an SQL UPDATE. saveOrUpdate() and replicate() result in either an INSERT or an UPDATE.

It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.

A Session instance is serializable if its persistent classes are serializable.

A typical transaction should use the following idiom:
 Session sess = factory.openSession();
 Transaction tx;
 try {
     tx = sess.beginTransaction();
     //do some work
     ...
     tx.commit();
 }
 catch (Exception e) {
     if (tx!=null) tx.rollback();
     throw e;
 }
 finally {
     sess.close();
 }
 

If the Session throws an exception, the transaction must be rolled back and the session discarded. The internal state of the Session might not be consistent with the database after the exception occurs.
SinceNot specified.
VersionNot specified.
AuthorGavin King
See also
Wiki javadoc Use textile entry format.
Add your comments here.
Method Summary
Transaction beginTransaction()
Begin a unit of work and return the associated Transaction object.
void cancelQuery()
Cancel execution of the current query.
void clear()
Completely clear the session.
Connection close()
End the Session by disconnecting from the JDBC connection and cleaning up.
Connection connection()
Get the JDBC connection of this Session.

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.
boolean contains( Object object )
Check if this instance is associated with this Session.
Criteria createCriteria( Class persistentClass )
Create a new Criteria instance, for the given entity class, or a superclass of an entity class.
Criteria createCriteria( Class persistentClass, String alias )
Create a new Criteria instance, for the given entity class, or a superclass of an entity class, with the given alias.
Criteria createCriteria( String entityName )
Create a new Criteria instance, for the given entity name.
Criteria createCriteria( String entityName, String alias )
Create a new Criteria instance, for the given entity name, with the given alias.
Query createFilter( Object collection, String queryString )
Create a new instance of Query for the given collection and filter string.
Query createQuery( String queryString )
Create a new instance of Query for the given HQL query string.
SQLQuery createSQLQuery( String queryString )
Create a new instance of SQLQuery for the given SQL query string.
void delete( Object object )
Remove a persistent instance from the datastore.
void delete( String entityName, Object object )
Remove a persistent instance from the datastore.
void disableFilter( String filterName )
Disable the named filter for the current session.
Connection disconnect()
Disconnect the Session from the current JDBC connection.
Filter enableFilter( String filterName )
Enable the named filter for this current session.
void evict( Object object )
Remove this instance from the session cache.
void flush()
Force the Session to flush.
Object get( Class clazz, Serializable id )
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.
Object get( Class clazz, Serializable id, LockMode lockMode )
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.
Object get( String entityName, Serializable id )
Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.
Object get( String entityName, Serializable id, LockMode lockMode )
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.
CacheMode getCacheMode()
Get the current cache mode.
LockMode getCurrentLockMode( Object object )
Determine the current lock mode of the given object.
Filter getEnabledFilter( String filterName )
Retrieve a currently enabled filter by name.
EntityMode getEntityMode()
Retrieve the entity mode in effect for this session.
String getEntityName( Object object )
Return the entity name for a persistent entity
FlushMode getFlushMode()
Get the current flush mode.
Serializable getIdentifier( Object object )
Return the identifier of an entity instance cached by the Session, or throw an exception if the instance is transient or associated with a different Session.
Query getNamedQuery( String queryName )
Obtain an instance of Query for a named query string defined in the mapping file.
Session getSession( EntityMode entityMode )
Starts a new Session with the given entity mode in effect.
SessionFactory getSessionFactory()
Get the SessionFactory that created this instance.
SessionStatistics getStatistics()
Get the statistics for this session.
Transaction getTransaction()
Get the Transaction instance associated with this session.
boolean isConnected()
Check if the Session is currently connected.
boolean isDirty()
Does this Session contain any changes which must be synchronized with the database? Would any SQL be executed if we flushed this session?
boolean isOpen()
Check if the Session is still open.
Object load( Class theClass, Serializable id, LockMode lockMode )
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
Object load( String entityName, Serializable id, LockMode lockMode )
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
Object load( Class theClass, Serializable id )
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.
Object load( String entityName, Serializable id )
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.
void load( Object object, Serializable id )
Read the persistent state associated with the given identifier into the given transient instance.
void lock( Object object, LockMode lockMode )
Obtain the specified lock level upon the given object.
void lock( String entityName, Object object, LockMode lockMode )
Obtain the specified lock level upon the given object.
Object merge( Object object )
Copy the state of the given object onto the persistent object with the same identifier.
Object merge( String entityName, Object object )
Copy the state of the given object onto the persistent object with the same identifier.
void persist( Object object )
Make a transient instance persistent.
void persist( String entityName, Object object )
Make a transient instance persistent.
void reconnect()
Obtain a new JDBC connection.
void reconnect( Connection connection )
Reconnect to the given JDBC connection.
void refresh( Object object )
Re-read the state of the given instance from the underlying database.
void refresh( Object object, LockMode lockMode )
Re-read the state of the given instance from the underlying database, with the given LockMode.
void replicate( Object object, ReplicationMode replicationMode )
Persist the state of the given detached instance, reusing the current identifier value.
void replicate( String entityName, Object object, ReplicationMode replicationMode )
Persist the state of the given detached instance, reusing the current identifier value.
Serializable save( Object object )
Persist the given transient instance, first assigning a generated identifier.
Serializable save( String entityName, Object object )
Persist the given transient instance, first assigning a generated identifier.
void saveOrUpdate( Object object )
Either save() or update() the given instance, depending upon the value of its identifier property.
void saveOrUpdate( String entityName, Object object )
Either save() or update() the given instance, depending upon the value of its identifier property.
void setCacheMode( CacheMode cacheMode )
Set the cache mode.
void setFlushMode( FlushMode flushMode )
Set the flush mode.
void setReadOnly( Object entity, boolean readOnly )
Set an unmodified persistent object to read only mode, or a read only object to modifiable mode.
void update( Object object )
Update the persistent instance with the identifier of the given detached instance.
void update( String entityName, Object object )
Update the persistent instance with the identifier of the given detached instance.
beginTransaction
public Transaction beginTransaction ( )
Begin a unit of work and return the associated Transaction object. If a new underlying transaction is required, begin the transaction. Otherwise continue the new work in the context of the existing underlying transaction. The class of the returned Transaction object is determined by the property hibernate.transaction_factory.
Exceptions
HibernateException No description provided.
See also
Wiki javadoc Use textile entry format.
Add your comments here.
cancelQuery
public void cancelQuery ( )
Cancel execution of the current query. May be called from one thread to stop execution of a query in another thread. Use with care!
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.

dsadasadasda

clear
public void clear ( )
Completely clear the session. Evict all loaded instances and cancel all pending saves, updates and deletions. Do not close open iterators or instances of ScrollableResults.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
close
public Connection close ( )
End the Session by disconnecting from the JDBC connection and cleaning up. It is not strictly necessary to close() the Session but you must at least disconnect() it.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
connection
public Connection connection ( )
Get the JDBC connection of this Session.

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 application should not close the connection.
Exceptions
HibernateException if the Session is disconnected
Wiki javadoc Use textile entry format.
Add your comments here.
contains
public boolean contains ( Object object )
Check if this instance is associated with this Session.
Parameters
TypeNameDescription
Object object an instance of a persistent class
Wiki javadoc Use textile entry format.
Add your comments here.
createCriteria
public Criteria createCriteria ( Class persistentClass )
Create a new Criteria instance, for the given entity class, or a superclass of an entity class.
Parameters
TypeNameDescription
Class persistentClass a class, which is persistent, or has persistent subclasses
Wiki javadoc Use textile entry format.
Add your comments here.
createCriteria
public Criteria createCriteria ( Class persistentClass, String alias )
Create a new Criteria instance, for the given entity class, or a superclass of an entity class, with the given alias.
Parameters
TypeNameDescription
Class persistentClass a class, which is persistent, or has persistent subclasses
String alias No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
createCriteria
public Criteria createCriteria ( String entityName )
Create a new Criteria instance, for the given entity name.
Parameters
TypeNameDescription
String entityName No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
createCriteria
public Criteria createCriteria ( String entityName, String alias )
Create a new Criteria instance, for the given entity name, with the given alias.
Parameters
TypeNameDescription
String entityName No description provided.
String alias No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
createFilter
public Query createFilter ( Object collection, String queryString )
Create a new instance of Query for the given collection and filter string.
Parameters
TypeNameDescription
Object collection a persistent collection
String queryString a Hibernate query
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
createQuery
public Query createQuery ( String queryString )
Create a new instance of Query for the given HQL query string.
Parameters
TypeNameDescription
String queryString a HQL query
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
createSQLQuery
public SQLQuery createSQLQuery ( String queryString )
Create a new instance of SQLQuery for the given SQL query string.
Parameters
TypeNameDescription
String queryString a SQL query
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
delete
public void delete ( Object object )
Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving Session or a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped with cascade="delete".
Parameters
TypeNameDescription
Object object the instance to be removed
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
delete
public void delete ( String entityName, Object object )
Remove a persistent instance from the datastore. The object argument may be an instance associated with the receiving Session or a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped with cascade="delete".
Parameters
TypeNameDescription
String entityName The entity name for the instance to be removed.
Object object the instance to be removed
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
disableFilter
public void disableFilter ( String filterName )
Disable the named filter for the current session.
Parameters
TypeNameDescription
String filterName The name of the filter to be disabled.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
disconnect
public Connection disconnect ( )
Disconnect the Session from the current JDBC connection. If the connection was obtained by Hibernate close it and return it to the connection pool; otherwise, return it to the application.

This is used by applications which supply JDBC connections to Hibernate and which require long-sessions (or long-conversations)

Note that disconnect() called on a session where the connection was retrieved by Hibernate through its configured ConnectionProvider has no effect, provided ON_CLOSE is not in effect.

Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
enableFilter
public Filter enableFilter ( String filterName )
Enable the named filter for this current session.
Parameters
TypeNameDescription
String filterName The name of the filter to be enabled.
Wiki javadoc Use textile entry format.
Add your comments here.
evict
public void evict ( 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 instances if the association is mapped with cascade="evict".
Parameters
TypeNameDescription
Object object a persistent instance
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
flush
public void flush ( )
Force the Session to flush. Must be called at the end of a unit of work, before commiting the transaction and closing the session (Transaction.commit() calls this method). Flushing is the process of synchronising the underlying persistent store with persistable state held in memory.
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
get
public Object get ( Class clazz, Serializable id )
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance, or a proxy for the instance, is already associated with the session, return that instance or proxy.)
Parameters
TypeNameDescription
Class clazz a persistent class
Serializable id an identifier
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
get
public Object get ( Class clazz, Serializable id, LockMode lockMode )
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. Obtain the specified lock mode if the instance exists.
Parameters
TypeNameDescription
Class clazz a persistent class
Serializable id an identifier
LockMode lockMode the lock mode
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
get
public Object get ( String entityName, Serializable id )
Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance. (If the instance, or a proxy for the instance, is already associated with the session, return that instance or proxy.)
Parameters
TypeNameDescription
String entityName the entity name
Serializable id an identifier
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
get
public Object get ( String entityName, Serializable id, LockMode lockMode )
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. Obtain the specified lock mode if the instance exists.
Parameters
TypeNameDescription
String entityName the entity name
Serializable id an identifier
LockMode lockMode the lock mode
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getCacheMode
public CacheMode getCacheMode ( )
Get the current cache mode.
Wiki javadoc Use textile entry format.
Add your comments here.
getCurrentLockMode
public LockMode getCurrentLockMode ( Object object )
Determine the current lock mode of the given object.
Parameters
TypeNameDescription
Object object a persistent instance
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getEnabledFilter
public Filter getEnabledFilter ( String filterName )
Retrieve a currently enabled filter by name.
Parameters
TypeNameDescription
String filterName The name of the filter to be retrieved.
Wiki javadoc Use textile entry format.
Add your comments here.
getEntityMode
public EntityMode getEntityMode ( )
Retrieve the entity mode in effect for this session.
Wiki javadoc Use textile entry format.
Add your comments here.
getEntityName
public String getEntityName ( Object object )
Return the entity name for a persistent entity
Parameters
TypeNameDescription
Object object a persistent entity
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getFlushMode
public FlushMode getFlushMode ( )
Get the current flush mode.
Wiki javadoc Use textile entry format.
Add your comments here.
getIdentifier
public Serializable getIdentifier ( Object object )
Return the identifier of an entity instance cached by the Session, or throw an exception if the instance is transient or associated with a different Session.
Parameters
TypeNameDescription
Object object a persistent instance
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getNamedQuery
public Query getNamedQuery ( String queryName )
Obtain an instance of Query for a named query string defined in the mapping file.
Parameters
TypeNameDescription
String queryName the name of a query defined externally
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getSession
public Session getSession ( EntityMode entityMode )
Starts a new Session with the given entity mode in effect. This secondary Session inherits the connection, transaction, and other context information from the primary Session. It doesn't need to be flushed or closed by the developer.
Parameters
TypeNameDescription
EntityMode entityMode The entity mode to use for the new session.
Wiki javadoc Use textile entry format.
Add your comments here.
getSessionFactory
public SessionFactory getSessionFactory ( )
Get the SessionFactory that created this instance.
See also
Wiki javadoc Use textile entry format.
Add your comments here.
getStatistics
public SessionStatistics getStatistics ( )
Get the statistics for this session.
Wiki javadoc Use textile entry format.
Add your comments here.
getTransaction
public Transaction getTransaction ( )
Get the Transaction instance associated with this session. The class of the returned Transaction object is determined by the property hibernate.transaction_factory.
See also
Wiki javadoc Use textile entry format.
Add your comments here.
isConnected
public boolean isConnected ( )
Check if the Session is currently connected.
Wiki javadoc Use textile entry format.
Add your comments here.
isDirty
public boolean isDirty ( )
Does this Session contain any changes which must be synchronized with the database? Would any SQL be executed if we flushed this session?
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
isOpen
public boolean isOpen ( )
Check if the Session is still open.
Wiki javadoc Use textile entry format.
Add your comments here.
load
public Object load ( Class theClass, Serializable id, LockMode lockMode )
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
Parameters
TypeNameDescription
Class theClass a persistent class
Serializable id a valid identifier of an existing persistent instance of the class
LockMode lockMode the lock level
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
load
public Object load ( String entityName, Serializable id, LockMode lockMode )
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
Parameters
TypeNameDescription
String entityName a persistent class
Serializable id a valid identifier of an existing persistent instance of the class
LockMode lockMode the lock level
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
load
public Object load ( Class theClass, Serializable id )
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.

You should not use this method to determine if an instance exists (use get() instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.
Parameters
TypeNameDescription
Class theClass a persistent class
Serializable id a valid identifier of an existing persistent instance of the class
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
load
public Object load ( String entityName, Serializable id )
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.

You should not use this method to determine if an instance exists (use get() instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.
Parameters
TypeNameDescription
String entityName a persistent class
Serializable id a valid identifier of an existing persistent instance of the class
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
load
public void load ( Object object, Serializable id )
Read the persistent state associated with the given identifier into the given transient instance.
Parameters
TypeNameDescription
Object object an "empty" instance of the persistent class
Serializable id a valid identifier of an existing persistent instance of the class
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
lock
public void lock ( Object object, LockMode lockMode )
Obtain the specified lock level upon the given object. This may be used to perform a version check (LockMode.READ), to upgrade to a pessimistic lock (LockMode.UPGRADE), or to simply reassociate a transient instance with a session (LockMode.NONE). This operation cascades to associated instances if the association is mapped with cascade="lock".
Parameters
TypeNameDescription
Object object a persistent or transient instance
LockMode lockMode the lock level
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
lock
public void lock ( String entityName, Object object, LockMode lockMode )
Obtain the specified lock level upon the given object. This may be used to perform a version check (LockMode.READ), to upgrade to a pessimistic lock (LockMode.UPGRADE), or to simply reassociate a transient instance with a session (LockMode.NONE). This operation cascades to associated instances if the association is mapped with cascade="lock".
Parameters
TypeNameDescription
String entityName No description provided.
Object object a persistent or transient instance
LockMode lockMode the lock level
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
merge
public Object merge ( Object object )
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 cascade="merge".

The semantics of this method are defined by JSR-220.
Parameters
TypeNameDescription
Object object a detached instance with state to be copied
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
merge
public Object merge ( String entityName, Object object )
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 cascade="merge".

The semantics of this method are defined by JSR-220.
Parameters
TypeNameDescription
String entityName No description provided.
Object object a detached instance with state to be copied
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
persist
public void persist ( Object object )
Make a transient instance persistent. This operation cascades to associated instances if the association is mapped with cascade="persist".

The semantics of this method are defined by JSR-220.
Parameters
TypeNameDescription
Object object a transient instance to be made persistent
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
persist
public void persist ( String entityName, Object object )
Make a transient instance persistent. This operation cascades to associated instances if the association is mapped with cascade="persist".

The semantics of this method are defined by JSR-220.
Parameters
TypeNameDescription
String entityName No description provided.
Object object a transient instance to be made persistent
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
reconnect
public void reconnect ( )
Obtain a new JDBC connection. This is used by applications which require long transactions and do not supply connections to the session.
Returns void No description provided.
Exceptions
HibernateException No description provided.
See also
Wiki javadoc Use textile entry format.
Add your comments here.
reconnect
public void reconnect ( Connection connection )
Reconnect to the given JDBC connection. This is used by applications which require long transactions and use application-supplied connections.
Parameters
TypeNameDescription
Connection connection a JDBC connection
Returns void No description provided.
Exceptions
HibernateException No description provided.
See also
Wiki javadoc Use textile entry format.
Add your comments here.
refresh
public void refresh ( Object object )
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
  • where a database trigger alters the object state upon insert or update
  • after executing direct SQL (eg. a mass update) in the same session
  • after inserting a Blob or Clob
Parameters
TypeNameDescription
Object object a persistent or detached instance
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
refresh
public void refresh ( Object object, LockMode lockMode )
Re-read the state of the given instance from the underlying database, with the given LockMode. 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.
Parameters
TypeNameDescription
Object object a persistent or detached instance
LockMode lockMode the lock mode to use
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
replicate
public void replicate ( Object object, ReplicationMode replicationMode )
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 cascade="replicate".
Parameters
TypeNameDescription
Object object a detached instance of a persistent class
ReplicationMode replicationMode No description provided.
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
replicate
public void replicate ( String entityName, Object object, ReplicationMode replicationMode )
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 cascade="replicate".
Parameters
TypeNameDescription
String entityName No description provided.
Object object a detached instance of a persistent class
ReplicationMode replicationMode No description provided.
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
save
public Serializable save ( Object object )
Persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.) This operation cascades to associated instances if the association is mapped with cascade="save-update".
Parameters
TypeNameDescription
Object object a transient instance of a persistent class
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
save
public Serializable save ( String entityName, Object object )
Persist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.) This operation cascades to associated instances if the association is mapped with cascade="save-update".
Parameters
TypeNameDescription
String entityName No description provided.
Object object a transient instance of a persistent class
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
saveOrUpdate
public void saveOrUpdate ( Object object )
Either save() or update() 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 unsaved-value attribute of the identifier property mapping. This operation cascades to associated instances if the association is mapped with cascade="save-update".
Parameters
TypeNameDescription
Object object a transient or detached instance containing new or updated state
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
saveOrUpdate
public void saveOrUpdate ( String entityName, Object object )
Either save() or update() 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 unsaved-value attribute of the identifier property mapping. This operation cascades to associated instances if the association is mapped with cascade="save-update".
Parameters
TypeNameDescription
String entityName No description provided.
Object object a transient or detached instance containing new or updated state
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setCacheMode
public void setCacheMode ( CacheMode cacheMode )
Set the cache mode.
Parameters
TypeNameDescription
CacheMode cacheMode No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
setFlushMode
public void setFlushMode ( FlushMode flushMode )
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 FlushMode.NEVER at the start of the session (in order to achieve some extra performance).
Parameters
TypeNameDescription
FlushMode flushMode the FlushMode
Returns void No description provided.
See also
Wiki javadoc Use textile entry format.
Add your comments here.
setReadOnly
public void setReadOnly ( Object entity, boolean readOnly )
Set an unmodified persistent object to read only mode, or a read only object to modifiable mode. In read only mode, no snapshot is maintained and the instance is never dirty checked.
Parameters
TypeNameDescription
Object entity No description provided.
boolean readOnly No description provided.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
update
public void update ( Object object )
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 cascade="save-update".
Parameters
TypeNameDescription
Object object a detached instance containing updated state
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
update
public void update ( String entityName, Object object )
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 cascade="save-update".
Parameters
TypeNameDescription
String entityName No description provided.
Object object a detached instance containing updated state
Returns void No description provided.
Exceptions
HibernateException No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.