Top Description Methods
org.hibernate

public Interface SharedSessionContract

extends QueryProducer, Serializable
Known Direct Subinterfaces
org.hibernate.StatelessSession, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.Session
Imports
java.io.Serializable, org.hibernate.jdbc.ReturningWork, .Work, org.hibernate.procedure.ProcedureCall, org.hibernate.query.QueryProducer

Contract methods shared between Session and StatelessSession.

NOTE : Poorly named. "shared" simply indicates that its a unified contract between Session and StatelessSession.

Author
Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public Transaction

Returns:

a Transaction instance
beginTransaction
()

Begin a unit of work and return the associated Transaction object.

public void
close()

End the session by releasing the JDBC connection and cleaning up.

public Criteria

Returns:

The criteria instance for manipulation and execution
createCriteria
(Class<T>
The class, which is an entity, or has entity subclasses/implementors
persistentClass
)

Deprecated (since 5.2) for Session, use the JPA Criteria
Create Criteria instance for the given class (entity or subclasses/implementors).
public Criteria

Returns:

The criteria instance for manipulation and execution
createCriteria
(Class<T>
The class, which is an entity, or has entity subclasses/implementors
persistentClass
,
String
The alias to use
alias
)

Deprecated (since 5.2) for Session, use the JPA Criteria
Create Criteria instance for the given class (entity or subclasses/implementors), using a specific alias.
public Criteria

Returns:

The criteria instance for manipulation and execution
createCriteria
(String
The entity name
entityName
)

Deprecated (since 5.2) for Session, use the JPA Criteria
Create Criteria instance for the given entity name.
public Criteria

Returns:

The criteria instance for manipulation and execution
createCriteria
(String
The entity name
entityName
,
String
The alias to use
alias
)

Deprecated (since 5.2) for Session, use the JPA Criteria
Create Criteria instance for the given entity name, using a specific alias.
public Query<R>
createQuery(String
The HQL/JPQL query
queryString
)

Redeclares org.hibernate.query.QueryProducer.createQuery.

Deprecated as a consequence of Query being deprecated.
Create a Query instance for the given HQL/JPQL query string.
public ProcedureCall

Returns:

The representation of the procedure call.
createStoredProcedureCall
(String
The name of the procedure.
procedureName
)

Deprecated as a consequence of ProcedureCall being deprecated.
Creates a call to a stored procedure.
public ProcedureCall

Returns:

The representation of the procedure call.
createStoredProcedureCall
(String
The name of the procedure.
procedureName
,
Class<T>...
The entity(s) to map the result on to.
resultClasses
)

Deprecated as a consequence of ProcedureCall being deprecated.
Creates a call to a stored procedure with specific result set entity mappings.
public ProcedureCall

Returns:

The representation of the procedure call.
createStoredProcedureCall
(String
The name of the procedure.
procedureName
,
String...
The explicit result set mapping(s) to use for mapping the results
resultSetMappings
)

Deprecated as a consequence of ProcedureCall being deprecated.
Creates a call to a stored procedure with specific result set entity mappings.
public default <
The type of the result returned from the work
T
>
T

Returns:

the result from calling ReturningWork#execute.
doReturningWork
(ReturningWork<T>
The work to be performed.
work
)

Controller for allowing users to perform JDBC related work using the Connection managed by this Session.

public default void
doWork(Work
The work to be performed.
work
)

Controller for allowing users to perform JDBC related work using the Connection managed by this Session.

public Integer

Returns:

Session-level JDBC batch size
getJdbcBatchSize
()

Get the Session-level JDBC batch size for the current Session.

public ProcedureCall

Returns:

The ProcedureCall
getNamedProcedureCall
(String
The name given to the template
name
)

Deprecated as a consequence of ProcedureCall being deprecated.
Gets a ProcedureCall based on a named template
public Query<R>
getNamedQuery(String
the name of a pre-defined, named query
queryName
)

Redeclares org.hibernate.query.QueryProducer.getNamedQuery.

Deprecated as a consequence of Query being deprecated.
Create a Query instance for the named query.
public String

Returns:

The tenant identifier associated with this session, or null
getTenantIdentifier
()

Obtain the tenant identifier associated with this session.

public Transaction

Returns:

a Transaction instance
getTransaction
()

Get the Transaction instance associated with this session.

public boolean

Returns:

boolean
isConnected
()

Check if the session is currently connected.

public boolean

Returns:

boolean
isOpen
()

Check if the session is still open.

public void
setJdbcBatchSize(Integer
Session-level JDBC batch size
jdbcBatchSize
)

Set the Session-level JDBC batch size.

Inherited from org.hibernate.query.QueryProducer:
createNamedQuerycreateNamedQuerycreateNativeQuerycreateNativeQuerycreateNativeQuerycreateQuerycreateQuerycreateQuerycreateQuerycreateSQLQuerygetNamedNativeQuerygetNamedSQLQuery

Method Detail

beginTransactionback to summary
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.

Returns:Transaction

a Transaction instance

See Also
getTransaction
closeback to summary
public void close() throws HibernateException

End the session by releasing the JDBC connection and cleaning up.

Exceptions
HibernateException:
Indicates problems cleaning up.
createCriteriaback to summary
public Criteria createCriteria(Class<T> persistentClass)

Deprecated

(since 5.2) for Session, use the JPA Criteria

Create Criteria instance for the given class (entity or subclasses/implementors).

Parameters
persistentClass:Class<T>

The class, which is an entity, or has entity subclasses/implementors

Returns:Criteria

The criteria instance for manipulation and execution

Annotations
@Deprecated
createCriteriaback to summary
public Criteria createCriteria(Class<T> persistentClass, String alias)

Deprecated

(since 5.2) for Session, use the JPA Criteria

Create Criteria instance for the given class (entity or subclasses/implementors), using a specific alias.

Parameters
persistentClass:Class<T>

The class, which is an entity, or has entity subclasses/implementors

alias:String

The alias to use

Returns:Criteria

The criteria instance for manipulation and execution

Annotations
@Deprecated
createCriteriaback to summary
public Criteria createCriteria(String entityName)

Deprecated

(since 5.2) for Session, use the JPA Criteria

Create Criteria instance for the given entity name.

Parameters
entityName:String

The entity name

Returns:Criteria

The criteria instance for manipulation and execution

Annotations
@Deprecated
createCriteriaback to summary
public Criteria createCriteria(String entityName, String alias)

Deprecated

(since 5.2) for Session, use the JPA Criteria

Create Criteria instance for the given entity name, using a specific alias.

Parameters
entityName:String

The entity name

alias:String

The alias to use

Returns:Criteria

The criteria instance for manipulation and execution

Annotations
@Deprecated
createQueryback to summary
public Query<R> createQuery(String queryString)

Redeclares org.hibernate.query.QueryProducer.createQuery.

Doc from org.hibernate.query.QueryProducer.createQuery.

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

Create a Query instance for the given HQL/JPQL query string.

Parameters
queryString:String

The HQL/JPQL query

Returns:Query<R>

The Query instance for manipulation and execution

Annotations
@Override
createStoredProcedureCallback to summary
public ProcedureCall createStoredProcedureCall(String procedureName)

Deprecated

as a consequence of ProcedureCall being deprecated. See corresponding docs for further information.

Creates a call to a stored procedure.

Parameters
procedureName:String

The name of the procedure.

Returns:ProcedureCall

The representation of the procedure call.

createStoredProcedureCallback to summary
public ProcedureCall createStoredProcedureCall(String procedureName, Class<T>... resultClasses)

Deprecated

as a consequence of ProcedureCall being deprecated. See corresponding docs for further information.

Creates a call to a stored procedure with specific result set entity mappings. Each class named is considered a "root return".

Parameters
procedureName:String

The name of the procedure.

resultClasses:Class<T>[]

The entity(s) to map the result on to.

Returns:ProcedureCall

The representation of the procedure call.

createStoredProcedureCallback to summary
public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)

Deprecated

as a consequence of ProcedureCall being deprecated. See corresponding docs for further information.

Creates a call to a stored procedure with specific result set entity mappings.

Parameters
procedureName:String

The name of the procedure.

resultSetMappings:String[]

The explicit result set mapping(s) to use for mapping the results

Returns:ProcedureCall

The representation of the procedure call.

doReturningWorkback to summary
public default <T> T doReturningWork(ReturningWork<T> work) throws HibernateException

Controller for allowing users to perform JDBC related work using the Connection managed by this Session. After execution returns the result of the ReturningWork#execute call.

Parameters
<T>
The type of the result returned from the work
work:ReturningWork<T>

The work to be performed.

Returns:T

the result from calling ReturningWork#execute.

Exceptions
HibernateException:
Generally indicates wrapped java.sql.SQLException
doWorkback to summary
public default void doWork(Work work) throws HibernateException

Controller for allowing users to perform JDBC related work using the Connection managed by this Session.

Parameters
work:Work

The work to be performed.

Exceptions
HibernateException:
Generally indicates wrapped java.sql.SQLException
getJdbcBatchSizeback to summary
public Integer getJdbcBatchSize()

Get the Session-level JDBC batch size for the current Session. Overrides the SessionFactory JDBC batch size defined by the hibernate.default_batch_fetch_size configuration property for the scope of the current Session.

Returns:Integer

Session-level JDBC batch size

Since
5.2
See Also
org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize, org.hibernate.boot.SessionFactoryBuilder#applyJdbcBatchSize
getNamedProcedureCallback to summary
public ProcedureCall getNamedProcedureCall(String name)

Deprecated

as a consequence of ProcedureCall being deprecated. See corresponding docs for further information.

Gets a ProcedureCall based on a named template

Parameters
name:String

The name given to the template

Returns:ProcedureCall

The ProcedureCall

See Also
javax.persistence.NamedStoredProcedureQuery
getNamedQueryback to summary
public Query<R> getNamedQuery(String queryName)

Redeclares org.hibernate.query.QueryProducer.getNamedQuery.

Doc from org.hibernate.query.QueryProducer.getNamedQuery.

Deprecated

as a consequence of Query being deprecated. See corresponding docs for further information.

Create a Query instance for the named query.

Parameters
queryName:String

the name of a pre-defined, named query

Returns:Query<R>

The Query instance for manipulation and execution

Annotations
@Override
getTenantIdentifierback to summary
public String getTenantIdentifier()

Obtain the tenant identifier associated with this session.

Returns:String

The tenant identifier associated with this session, or null

getTransactionback to summary
public Transaction getTransaction()

Get the Transaction instance associated with this session. The concrete type of the returned Transaction object is determined by the hibernate.transaction_factory property.

Returns:Transaction

a Transaction instance

isConnectedback to summary
public boolean isConnected()

Check if the session is currently connected.

Returns:boolean

boolean

isOpenback to summary
public boolean isOpen()

Check if the session is still open.

Returns:boolean

boolean

setJdbcBatchSizeback to summary
public void setJdbcBatchSize(Integer jdbcBatchSize)

Set the Session-level JDBC batch size. Overrides the SessionFactory JDBC batch size defined by the hibernate.default_batch_fetch_size configuration property for the scope of the current Session.

Parameters
jdbcBatchSize:Integer

Session-level JDBC batch size

Since
5.2
See Also
org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize, org.hibernate.boot.SessionFactoryBuilder#applyJdbcBatchSize