Top Description Methods
org.hibernate.classic

public Interface Session

extends Session
Known Direct Implementers
org.hibernate.impl.SessionImpl
Imports
java.io.Serializable, java.util.Collection, .Iterator, .List, org.hibernate.HibernateException, .Query, .SQLQuery, org.hibernate.type.Type

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

Method Summary

Modifier and TypeMethod and Description
public Query
createSQLQuery(String
a query expressed in SQL
sql
,
String
a table alias that appears inside {} in the SQL string
returnAlias
,
Class<T>
the returned persistent class
returnClass
)

Deprecated use org.hibernate.SQLQuery#addRoot or org.hibernate.SQLQuery#addEntity variants instead to define the alias/class
Create a new instance of Query for the given SQL string.
public Query
createSQLQuery(String
a query expressed in SQL
sql
,
String[]
an array of table aliases that appear inside {} in the SQL string
returnAliases
,
Class<T>[]
the returned persistent classes
returnClasses
)

Deprecated use org.hibernate.SQLQuery#addRoot or org.hibernate.SQLQuery#addEntity variants instead to define the aliases/classes
Create a new instance of Query for the given SQL string.
public int

Returns:

the number of instances deleted
delete
(String
the query string
query
)

Deprecated consider using HQL delete statements
Delete all objects returned by the query.
public int

Returns:

the number of instances deleted
delete
(String
the query string
query
,
Object
a value to be witten to a "?" placeholder in the query string.
value
,
Type
the hibernate type of value.
type
)

Deprecated consider using HQL delete statements
Delete all objects returned by the query.
public int

Returns:

the number of instances deleted
delete
(String
the query string
query
,
Object[]
a list of values to be written to "?" placeholders in the query.
values
,
Type[]
a list of Hibernate types of the values
types
)

Deprecated consider using HQL delete statements
Delete all objects returned by the query.
public Collection<E>

Returns:

Collection the resulting collection
filter
(Object
a persistent collection to filter
collection
,
String
a filter query string
filter
)

Apply a filter to a persistent collection.
public Collection<E>

Returns:

Collection
filter
(Object
a persistent collection to filter
collection
,
String
a filter query string
filter
,
Object
a value to be witten to a "?" placeholder in the query string
value
,
Type
the hibernate type of value
type
)

Deprecated use createFilter(Object, String).setXYZ.
Apply a filter to a persistent collection.
public Collection<E>

Returns:

Collection
filter
(Object
a persistent collection to filter
collection
,
String
a filter query string
filter
,
Object[]
a list of values to be written to "?" placeholders in the query
values
,
Type[]
a list of Hibernate types of the values
types
)

Deprecated use createFilter(Object, String).setXYZ.
Apply a filter to a persistent collection.
public List<E>

Returns:

a distinct list of instances (or arrays of instances)
find
(String
a query expressed in Hibernate's query language
query
)

Deprecated use createQuery.Query#list()
Execute a query.
public List<E>

Returns:

a distinct list of instances (or arrays of instances)
find
(String
the query string
query
,
Object
a value to be bound to a "?" placeholder (JDBC IN parameter).
value
,
Type
the Hibernate type of the value
type
)

Deprecated use createQuery.setXYZ.Query#list()
Execute a query with bind parameters, binding a value to a "?" parameter in the query string.
public List<E>

Returns:

a distinct list of instances
find
(String
the query string
query
,
Object[]
an array of values to be bound to the "?" placeholders (JDBC IN parameters).
values
,
Type[]
an array of Hibernate types of the values
types
)

Deprecated use createQuery.setXYZ.Query#list()
Execute a query with bind parameters, binding an array of values to "?" parameters in the query string.
public Iterator<E>

Returns:

an iterator
iterate
(String
the query string
query
)

Deprecated use createQuery.Query#iterate
Execute a query and return the results in an iterator.
public Iterator<E>

Returns:

an iterator
iterate
(String
the query string
query
,
Object
a value to be witten to a "?" placeholder in the query string
value
,
Type
the hibernate type of value
type
)

Deprecated use createQuery.setXYZ.Query#iterate
Execute a query and return the results in an iterator.
public Iterator<E>

Returns:

an iterator
iterate
(String
the query string
query
,
Object[]
a list of values to be written to "?" placeholders in the query
values
,
Type[]
a list of Hibernate types of the values
types
)

Deprecated use createQuery.setXYZ.Query#iterate
Execute a query and return the results in an iterator.
public void
save(Object
a transient instance of a persistent class
object
,
Serializable
an unused valid identifier
id
)

Deprecated declare identifier properties for all classes
Persist the given transient instance, using the given identifier.
public void
save(String entityName, Object
a transient instance of a persistent class
object
,
Serializable
an unused valid identifier
id
)

Deprecated declare identifier properties for all classes
Persist the given transient instance, using the given identifier.
public Object

Returns:

an updated persistent instance
saveOrUpdateCopy
(Object
a transient instance with state to be copied
object
)

Copy the state of the given object onto the persistent object with the same identifier.
public Object

Returns:

an updated persistent instance
saveOrUpdateCopy
(Object
a persistent or transient instance with state to be copied
object
,
Serializable
the identifier of the instance to copy to
id
)

Deprecated with no replacement
Copy the state of the given object onto the persistent object with the given identifier.
public Object

Returns:

an updated persistent instance
saveOrUpdateCopy
(String entityName, Object
a transient instance with state to be copied
object
)

Copy the state of the given object onto the persistent object with the same identifier.
public Object

Returns:

an updated persistent instance
saveOrUpdateCopy
(String entityName, Object
a persistent or transient instance with state to be copied
object
,
Serializable
the identifier of the instance to copy to
id
)

Deprecated with no replacement
Copy the state of the given object onto the persistent object with the given identifier.
public void
update(Object
a detached instance containing updated state
object
,
Serializable
identifier of persistent instance
id
)

Deprecated declare identifier properties for all classes
Update the persistent state associated with the given identifier.
public void
update(String entityName, Object
a detached instance containing updated state
object
,
Serializable
identifier of persistent instance
id
)

Deprecated declare identifier properties for all classes
Update the persistent state associated with the given identifier.
Inherited from org.hibernate.Session:
beginTransactionbuildLockRequestcancelQueryclearcloseconnectioncontainscreateCriteriacreateCriteriacreateCriteriacreateCriteriacreateFiltercreateQuerycreateSQLQuerydeletedeletedisableFetchProfiledisableFilterdisconnectdoWorkenableFetchProfileenableFilterevictflushgetgetgetgetgetgetgetCacheModegetCurrentLockModegetEnabledFiltergetEntityModegetEntityNamegetFlushModegetIdentifiergetLobHelpergetNamedQuerygetSessiongetSessionFactorygetStatisticsgetTransactiongetTypeHelperisConnectedisDefaultReadOnlyisDirtyisFetchProfileEnabledisOpenisReadOnlyloadloadloadloadloadloadloadlocklockmergemergepersistpersistreconnectreconnectrefreshrefreshrefreshreplicatereplicatesavesavesaveOrUpdatesaveOrUpdatesetCacheModesetDefaultReadOnlysetFlushModesetReadOnlyupdateupdate

Method Detail

createSQLQueryback to summary
public Query createSQLQuery(String sql, String returnAlias, Class<T> returnClass)

Deprecated

use org.hibernate.SQLQuery#addRoot or org.hibernate.SQLQuery#addEntity variants instead to define the alias/class

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

Returned instances should all be org.hibernate.SQLQuery.

Parameters
sql:String

a query expressed in SQL

returnAlias:String

a table alias that appears inside {} in the SQL string

returnClass:Class<T>

the returned persistent class

Annotations
@Deprecated
@SuppressWarnings:JavaDoc
createSQLQueryback to summary
public Query createSQLQuery(String sql, String[] returnAliases, Class<T>[] returnClasses)

Deprecated

use org.hibernate.SQLQuery#addRoot or org.hibernate.SQLQuery#addEntity variants instead to define the aliases/classes

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

Returned instances should all be org.hibernate.SQLQuery.

Parameters
sql:String

a query expressed in SQL

returnAliases:String[]

an array of table aliases that appear inside {} in the SQL string

returnClasses:Class<T>[]

the returned persistent classes

Annotations
@Deprecated
@SuppressWarnings:JavaDoc
deleteback to summary
public 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 delete(Object) individually.

Parameters
query:String

the query string

Returns:int

the number of instances deleted

deleteback to summary
public 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 delete(Object) individually.

Parameters
query:String

the query string

value:Object

a value to be witten to a "?" placeholder in the query string.

type:Type

the hibernate type of value.

Returns:int

the number of instances deleted

deleteback to summary
public 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 delete(Object) individually.

Parameters
query:String

the query string

values:Object[]

a list of values to be written to "?" placeholders in the query.

types:Type[]

a list of Hibernate types of the values

Returns:int

the number of instances deleted

filterback to summary
public Collection<E> filter(Object collection, String filter) throws HibernateException

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:Object

a persistent collection to filter

filter:String

a filter query string

Returns:Collection<E>

Collection the resulting collection

filterback to summary
public Collection<E> filter(Object collection, String filter, Object value, Type type) throws HibernateException

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

Parameters
collection:Object

a persistent collection to filter

filter:String

a filter query string

value:Object

a value to be witten to a "?" placeholder in the query string

type:Type

the hibernate type of value

Returns:Collection<E>

Collection

filterback to summary
public Collection<E> filter(Object collection, String filter, Object[] values, Type[] types) throws HibernateException

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:Object

a persistent collection to filter

filter:String

a filter query string

values:Object[]

a list of values to be written to "?" placeholders in the query

types:Type[]

a list of Hibernate types of the values

Returns:Collection<E>

Collection

findback to summary
public List<E> find(String query) throws HibernateException

Deprecated

use createQuery.Query#list()

Execute a query.

Parameters
query:String

a query expressed in Hibernate's query language

Returns:List<E>

a distinct list of instances (or arrays of instances)

findback to summary
public List<E> find(String query, Object value, Type type) throws HibernateException

Deprecated

use createQuery.setXYZ.Query#list()

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

Parameters
query:String

the query string

value:Object

a value to be bound to a "?" placeholder (JDBC IN parameter).

type:Type

the Hibernate type of the value

Returns:List<E>

a distinct list of instances (or arrays of instances)

See Also
for access to <tt>Type</tt> instances
findback to summary
public List<E> find(String query, Object[] values, Type[] types) throws HibernateException

Deprecated

use createQuery.setXYZ.Query#list()

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

Parameters
query:String

the query string

values:Object[]

an array of values to be bound to the "?" placeholders (JDBC IN parameters).

types:Type[]

an array of Hibernate types of the values

Returns:List<E>

a distinct list of instances

See Also
for access to <tt>Type</tt> instances
iterateback to summary
public Iterator<E> iterate(String query) throws HibernateException

Deprecated

use createQuery.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:String

the query string

Returns:Iterator<E>

an iterator

iterateback to summary
public Iterator<E> iterate(String query, Object value, Type type) throws HibernateException

Deprecated

use createQuery.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:String

the query string

value:Object

a value to be witten to a "?" placeholder in the query string

type:Type

the hibernate type of value

Returns:Iterator<E>

an iterator

iterateback to summary
public Iterator<E> iterate(String query, Object[] values, Type[] types) throws HibernateException

Deprecated

use createQuery.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:String

the query string

values:Object[]

a list of values to be written to "?" placeholders in the query

types:Type[]

a list of Hibernate types of the values

Returns:Iterator<E>

an iterator

saveback to summary
public 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:Object

a transient instance of a persistent class

id:Serializable

an unused valid identifier

saveback to summary
public 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:Object

a transient instance of a persistent class

id:Serializable

an unused valid identifier

saveOrUpdateCopyback to summary
public Object saveOrUpdateCopy(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 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:Object

a transient instance with state to be copied

Returns:Object

an updated persistent instance

saveOrUpdateCopyback to summary
public 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:Object

a persistent or transient instance with state to be copied

id:Serializable

the identifier of the instance to copy to

Returns:Object

an updated persistent instance

saveOrUpdateCopyback to summary
public Object saveOrUpdateCopy(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 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:Object

a transient instance with state to be copied

Returns:Object

an updated persistent instance

saveOrUpdateCopyback to summary
public 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:Object

a persistent or transient instance with state to be copied

id:Serializable

the identifier of the instance to copy to

Returns:Object

an updated persistent instance

updateback to summary
public 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:Object

a detached instance containing updated state

id:Serializable

identifier of persistent instance

updateback to summary
public 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:Object

a detached instance containing updated state

id:Serializable

identifier of persistent instance