org.hibernate.classic
Interface Session

All Superinterfaces:
Serializable, Session

public interface Session
extends Session

An extension of the Session API, including all deprecated methods from Hibernate2. This interface is provided to allow easier migration of existing applications. New code should use org.hibernate.Session.

Author:
Gavin King

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.hibernate.Session
Session.LockRequest
 
Method Summary
 Query createSQLQuery(String sql, String[] returnAliases, Class[] returnClasses)
          Deprecated. will be replaced with a more Query like interface in later release
 Query createSQLQuery(String sql, String returnAlias, Class returnClass)
          Deprecated. will be replaced with a more Query like interface in later release
 int delete(String query)
          Deprecated. consider using HQL delete statements
 int delete(String query, Object[] values, Type[] types)
          Deprecated. consider using HQL delete statements
 int delete(String query, Object value, Type type)
          Deprecated. consider using HQL delete statements
 Collection filter(Object collection, String filter)
          Deprecated. use Session.createFilter(Object, String).Query.list()
 Collection filter(Object collection, String filter, Object[] values, Type[] types)
          Deprecated. use Session.createFilter(Object, String).setXYZ.Query.list()
 Collection filter(Object collection, String filter, Object value, Type type)
          Deprecated. use Session.createFilter(Object, String).setXYZ.Query.list()
 List find(String query)
          Deprecated. use Session.createQuery(java.lang.String).Query.list()
 List find(String query, Object[] values, Type[] types)
          Deprecated. use Session.createQuery(java.lang.String).setXYZ.Query.list()
 List find(String query, Object value, Type type)
          Deprecated. use Session.createQuery(java.lang.String).setXYZ.Query.list()
 Iterator iterate(String query)
          Deprecated. use Session.createQuery(java.lang.String).Query.iterate()
 Iterator iterate(String query, Object[] values, Type[] types)
          Deprecated. use Session.createQuery(java.lang.String).setXYZ.Query.iterate()
 Iterator iterate(String query, Object value, Type type)
          Deprecated. use Session.createQuery(java.lang.String).setXYZ.Query.iterate()
 void save(Object object, Serializable id)
          Deprecated. declare identifier properties for all classes
 void save(String entityName, Object object, Serializable id)
          Deprecated. declare identifier properties for all classes
 Object saveOrUpdateCopy(Object object)
          Deprecated. use Session.merge(Object)
 Object saveOrUpdateCopy(Object object, Serializable id)
          Deprecated. with no replacement
 Object saveOrUpdateCopy(String entityName, Object object)
          Deprecated. use Session.merge(String, Object)
 Object saveOrUpdateCopy(String entityName, Object object, Serializable id)
          Deprecated. with no replacement
 void update(Object object, Serializable id)
          Deprecated. declare identifier properties for all classes
 void update(String entityName, Object object, Serializable id)
          Deprecated. declare identifier properties for all classes
 
Methods inherited from interface org.hibernate.Session
beginTransaction, buildLockRequest, cancelQuery, clear, close, connection, contains, createCriteria, createCriteria, createCriteria, createCriteria, createFilter, createQuery, createSQLQuery, delete, delete, disableFetchProfile, disableFilter, disconnect, doWork, enableFetchProfile, enableFilter, evict, flush, get, get, get, get, get, get, getCacheMode, getCurrentLockMode, getEnabledFilter, getEntityMode, getEntityName, getFlushMode, getIdentifier, getNamedQuery, getSession, getSessionFactory, getStatistics, getTransaction, isConnected, isDefaultReadOnly, isDirty, isFetchProfileEnabled, isOpen, isReadOnly, load, load, load, load, load, load, load, lock, lock, merge, merge, persist, persist, reconnect, reconnect, refresh, refresh, refresh, replicate, replicate, save, save, saveOrUpdate, saveOrUpdate, setCacheMode, setDefaultReadOnly, setFlushMode, setReadOnly, update, update
 

Method Detail

saveOrUpdateCopy

Object saveOrUpdateCopy(Object object)
                        throws HibernateException
Deprecated. use Session.merge(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 or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.

Parameters:
object - a transient instance with state to be copied
Returns:
an updated persistent instance
Throws:
HibernateException

saveOrUpdateCopy

Object saveOrUpdateCopy(Object object,
                        Serializable id)
                        throws HibernateException
Deprecated. with no replacement

Copy the state of the given object onto the persistent object with the given identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If there is no database row with the given identifier, save the given instance and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.

Parameters:
object - a persistent or transient instance with state to be copied
id - the identifier of the instance to copy to
Returns:
an updated persistent instance
Throws:
HibernateException

saveOrUpdateCopy

Object saveOrUpdateCopy(String entityName,
                        Object object)
                        throws HibernateException
Deprecated. use Session.merge(String, 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 or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.

Parameters:
object - a transient instance with state to be copied
Returns:
an updated persistent instance
Throws:
HibernateException

saveOrUpdateCopy

Object saveOrUpdateCopy(String entityName,
                        Object object,
                        Serializable id)
                        throws HibernateException
Deprecated. with no replacement

Copy the state of the given object onto the persistent object with the given identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If there is no database row with the given identifier, save the given instance and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.

Parameters:
object - a persistent or transient instance with state to be copied
id - the identifier of the instance to copy to
Returns:
an updated persistent instance
Throws:
HibernateException

find

List find(String query)
          throws HibernateException
Deprecated. use Session.createQuery(java.lang.String).Query.list()

Execute a query.

Parameters:
query - a query expressed in Hibernate's query language
Returns:
a distinct list of instances (or arrays of instances)
Throws:
HibernateException

find

List find(String query,
          Object value,
          Type type)
          throws HibernateException
Deprecated. use Session.createQuery(java.lang.String).setXYZ.Query.list()

Execute a query with bind parameters, binding a value to a "?" parameter in the query string.

Parameters:
query - the query string
value - a value to be bound to a "?" placeholder (JDBC IN parameter).
type - the Hibernate type of the value
Returns:
a distinct list of instances (or arrays of instances)
Throws:
HibernateException
See Also:
for access to Type instances

find

List find(String query,
          Object[] values,
          Type[] types)
          throws HibernateException
Deprecated. use Session.createQuery(java.lang.String).setXYZ.Query.list()

Execute a query with bind parameters, binding an array of values to "?" parameters in the query string.

Parameters:
query - the query string
values - an array of values to be bound to the "?" placeholders (JDBC IN parameters).
types - an array of Hibernate types of the values
Returns:
a distinct list of instances
Throws:
HibernateException
See Also:
for access to Type instances

iterate

Iterator iterate(String query)
                 throws HibernateException
Deprecated. use Session.createQuery(java.lang.String).Query.iterate()

Execute a query and return the results in an iterator. If the query has multiple return values, values will be returned in an array of type Object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only. So iterate() is usually a less efficient way to retrieve objects than find().

Parameters:
query - the query string
Returns:
an iterator
Throws:
HibernateException

iterate

Iterator iterate(String query,
                 Object value,
                 Type type)
                 throws HibernateException
Deprecated. use Session.createQuery(java.lang.String).setXYZ.Query.iterate()

Execute a query and return the results in an iterator. Write the given value to "?" in the query string. If the query has multiple return values, values will be returned in an array of type Object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only. So iterate() is usually a less efficient way to retrieve objects than find().

Parameters:
query - the query string
value - a value to be witten to a "?" placeholder in the query string
type - the hibernate type of value
Returns:
an iterator
Throws:
HibernateException

iterate

Iterator iterate(String query,
                 Object[] values,
                 Type[] types)
                 throws HibernateException
Deprecated. use Session.createQuery(java.lang.String).setXYZ.Query.iterate()

Execute a query and return the results in an iterator. Write the given values to "?" in the query string. If the query has multiple return values, values will be returned in an array of type Object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only. So iterate() is usually a less efficient way to retrieve objects than find().

Parameters:
query - the query string
values - a list of values to be written to "?" placeholders in the query
types - a list of Hibernate types of the values
Returns:
an iterator
Throws:
HibernateException

filter

Collection filter(Object collection,
                  String filter)
                  throws HibernateException
Deprecated. use Session.createFilter(Object, String).Query.list()

Apply a filter to a persistent collection. A filter is a Hibernate query that may refer to this, the collection element. Filters allow efficient access to very large lazy collections. (Executing the filter does not initialize the collection.)

Parameters:
collection - a persistent collection to filter
filter - a filter query string
Returns:
Collection the resulting collection
Throws:
HibernateException

filter

Collection filter(Object collection,
                  String filter,
                  Object value,
                  Type type)
                  throws HibernateException
Deprecated. use Session.createFilter(Object, String).setXYZ.Query.list()

Apply a filter to a persistent collection. A filter is a Hibernate query that may refer to this, the collection element.

Parameters:
collection - a persistent collection to filter
filter - a filter query string
value - a value to be witten to a "?" placeholder in the query string
type - the hibernate type of value
Returns:
Collection
Throws:
HibernateException

filter

Collection filter(Object collection,
                  String filter,
                  Object[] values,
                  Type[] types)
                  throws HibernateException
Deprecated. use Session.createFilter(Object, String).setXYZ.Query.list()

Apply a filter to a persistent collection. Bind the given parameters to "?" placeholders. A filter is a Hibernate query that may refer to this, the collection element.

Parameters:
collection - a persistent collection to filter
filter - a filter query string
values - a list of values to be written to "?" placeholders in the query
types - a list of Hibernate types of the values
Returns:
Collection
Throws:
HibernateException

delete

int delete(String query)
           throws HibernateException
Deprecated. consider using HQL delete statements

Delete all objects returned by the query. Return the number of objects deleted.

Note that this is very different from the delete-statement support added in HQL since 3.1. The functionality here is to actually peform the query and then iterate the results calling Session.delete(Object) individually.

Parameters:
query - the query string
Returns:
the number of instances deleted
Throws:
HibernateException

delete

int delete(String query,
           Object value,
           Type type)
           throws HibernateException
Deprecated. consider using HQL delete statements

Delete all objects returned by the query. Return the number of objects deleted.

Note that this is very different from the delete-statement support added in HQL since 3.1. The functionality here is to actually peform the query and then iterate the results calling Session.delete(Object) individually.

Parameters:
query - the query string
value - a value to be witten to a "?" placeholder in the query string.
type - the hibernate type of value.
Returns:
the number of instances deleted
Throws:
HibernateException

delete

int delete(String query,
           Object[] values,
           Type[] types)
           throws HibernateException
Deprecated. consider using HQL delete statements

Delete all objects returned by the query. Return the number of objects deleted.

Note that this is very different from the delete-statement support added in HQL since 3.1. The functionality here is to actually peform the query and then iterate the results calling Session.delete(Object) individually.

Parameters:
query - the query string
values - a list of values to be written to "?" placeholders in the query.
types - a list of Hibernate types of the values
Returns:
the number of instances deleted
Throws:
HibernateException

createSQLQuery

Query createSQLQuery(String sql,
                     String returnAlias,
                     Class returnClass)
Deprecated. will be replaced with a more Query like interface in later release

Create a new instance of Query for the given SQL string.

Parameters:
sql - a query expressed in SQL
returnAlias - a table alias that appears inside {} in the SQL string
returnClass - the returned persistent class

createSQLQuery

Query createSQLQuery(String sql,
                     String[] returnAliases,
                     Class[] returnClasses)
Deprecated. will be replaced with a more Query like interface in later release

Create a new instance of Query for the given SQL string.

Parameters:
sql - a query expressed in SQL
returnAliases - an array of table aliases that appear inside {} in the SQL string
returnClasses - the returned persistent classes

save

void save(Object object,
          Serializable id)
          throws HibernateException
Deprecated. declare identifier properties for all classes

Persist the given transient instance, using the given identifier. This operation cascades to associated instances if the association is mapped with cascade="save-update".

Parameters:
object - a transient instance of a persistent class
id - an unused valid identifier
Throws:
HibernateException

save

void save(String entityName,
          Object object,
          Serializable id)
          throws HibernateException
Deprecated. declare identifier properties for all classes

Persist the given transient instance, using the given identifier. This operation cascades to associated instances if the association is mapped with cascade="save-update".

Parameters:
object - a transient instance of a persistent class
id - an unused valid identifier
Throws:
HibernateException

update

void update(Object object,
            Serializable id)
            throws HibernateException
Deprecated. declare identifier properties for all classes

Update the persistent state associated with the given identifier. An exception is thrown if there is a persistent instance with the same identifier in the current session. This operation cascades to associated instances if the association is mapped with cascade="save-update".

Parameters:
object - a detached instance containing updated state
id - identifier of persistent instance
Throws:
HibernateException

update

void update(String entityName,
            Object object,
            Serializable id)
            throws HibernateException
Deprecated. declare identifier properties for all classes

Update the persistent state associated with the given identifier. An exception is thrown if there is a persistent instance with the same identifier in the current session. This operation cascades to associated instances if the association is mapped with cascade="save-update".

Parameters:
object - a detached instance containing updated state
id - identifier of persistent instance
Throws:
HibernateException


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.