/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */
package org.hibernate;

import java.io.Serializable;

import org.hibernate.procedure.ProcedureCall;
import 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
/** * Contract methods shared between {@link Session} and {@link StatelessSession}. * <p/> * NOTE : Poorly named. "shared" simply indicates that its a unified contract between {@link Session} and * {@link StatelessSession}. * * @author Steve Ebersole */
public interface SharedSessionContract extends QueryProducer, Serializable {
Obtain the tenant identifier associated with this session.
Returns:The tenant identifier associated with this session, or null
/** * Obtain the tenant identifier associated with this session. * * @return The tenant identifier associated with this session, or {@code null} */
String getTenantIdentifier();
End the session by releasing the JDBC connection and cleaning up.
Throws:
  • HibernateException – Indicates problems cleaning up.
/** * End the session by releasing the JDBC connection and cleaning up. * * @throws HibernateException Indicates problems cleaning up. */
void close() throws HibernateException;
Check if the session is still open.
Returns:boolean
/** * Check if the session is still open. * * @return boolean */
boolean isOpen();
Check if the session is currently connected.
Returns:boolean
/** * Check if the session is currently connected. * * @return boolean */
boolean isConnected();
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.
See Also:
Returns:a Transaction instance
/** * Begin a unit of work and return the associated {@link 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. * * @return a Transaction instance * * @see #getTransaction */
Transaction beginTransaction();
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:a Transaction instance
/** * Get the {@link Transaction} instance associated with this session. The concrete type of the returned * {@link Transaction} object is determined by the {@code hibernate.transaction_factory} property. * * @return a Transaction instance */
Transaction getTransaction();
Gets a ProcedureCall based on a named template
Params:
  • name – The name given to the template
See Also:
Returns:The ProcedureCall
/** * Gets a ProcedureCall based on a named template * * @param name The name given to the template * * @return The ProcedureCall * * @see javax.persistence.NamedStoredProcedureQuery */
ProcedureCall getNamedProcedureCall(String name);
Creates a call to a stored procedure.
Params:
  • procedureName – The name of the procedure.
Returns:The representation of the procedure call.
/** * Creates a call to a stored procedure. * * @param procedureName The name of the procedure. * * @return The representation of the procedure call. */
ProcedureCall createStoredProcedureCall(String procedureName);
Creates a call to a stored procedure with specific result set entity mappings. Each class named is considered a "root return".
Params:
  • procedureName – The name of the procedure.
  • resultClasses – The entity(s) to map the result on to.
Returns:The representation of the procedure call.
/** * Creates a call to a stored procedure with specific result set entity mappings. Each class named * is considered a "root return". * * @param procedureName The name of the procedure. * @param resultClasses The entity(s) to map the result on to. * * @return The representation of the procedure call. */
ProcedureCall createStoredProcedureCall(String procedureName, Class... resultClasses);
Creates a call to a stored procedure with specific result set entity mappings.
Params:
  • procedureName – The name of the procedure.
  • resultSetMappings – The explicit result set mapping(s) to use for mapping the results
Returns:The representation of the procedure call.
/** * Creates a call to a stored procedure with specific result set entity mappings. * * @param procedureName The name of the procedure. * @param resultSetMappings The explicit result set mapping(s) to use for mapping the results * * @return The representation of the procedure call. */
ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings);
Create Criteria instance for the given class (entity or subclasses/implementors).
Params:
  • persistentClass – The class, which is an entity, or has entity subclasses/implementors
Returns:The criteria instance for manipulation and execution
Deprecated:(since 5.2) for Session, use the JPA Criteria
/** * Create {@link Criteria} instance for the given class (entity or subclasses/implementors). * * @param persistentClass The class, which is an entity, or has entity subclasses/implementors * * @return The criteria instance for manipulation and execution * * @deprecated (since 5.2) for Session, use the JPA Criteria */
@Deprecated Criteria createCriteria(Class persistentClass);
Create Criteria instance for the given class (entity or subclasses/implementors), using a specific alias.
Params:
  • persistentClass – The class, which is an entity, or has entity subclasses/implementors
  • alias – The alias to use
Returns:The criteria instance for manipulation and execution
Deprecated:(since 5.2) for Session, use the JPA Criteria
/** * Create {@link Criteria} instance for the given class (entity or subclasses/implementors), using a specific * alias. * * @param persistentClass The class, which is an entity, or has entity subclasses/implementors * @param alias The alias to use * * @return The criteria instance for manipulation and execution * * @deprecated (since 5.2) for Session, use the JPA Criteria */
@Deprecated Criteria createCriteria(Class persistentClass, String alias);
Create Criteria instance for the given entity name.
Params:
  • entityName – The entity name
Returns:The criteria instance for manipulation and execution
Deprecated:(since 5.2) for Session, use the JPA Criteria
/** * Create {@link Criteria} instance for the given entity name. * * @param entityName The entity name * @return The criteria instance for manipulation and execution * * @deprecated (since 5.2) for Session, use the JPA Criteria */
@Deprecated Criteria createCriteria(String entityName);
Create Criteria instance for the given entity name, using a specific alias.
Params:
  • entityName – The entity name
  • alias – The alias to use
Returns:The criteria instance for manipulation and execution
Deprecated:(since 5.2) for Session, use the JPA Criteria
/** * Create {@link Criteria} instance for the given entity name, using a specific alias. * * @param entityName The entity name * @param alias The alias to use * * @return The criteria instance for manipulation and execution * * @deprecated (since 5.2) for Session, use the JPA Criteria */
@Deprecated Criteria createCriteria(String entityName, String alias);
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.
See Also:
Returns:Session-level JDBC batch size
Since:5.2
/** * Get the Session-level JDBC batch size for the current Session. * Overrides the SessionFactory JDBC batch size defined by the {@code hibernate.default_batch_fetch_size} configuration property for the scope of the current {@code Session}. * * @return Session-level JDBC batch size * * @since 5.2 * * @see org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize * @see org.hibernate.boot.SessionFactoryBuilder#applyJdbcBatchSize */
Integer getJdbcBatchSize();
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.
Params:
  • jdbcBatchSize – Session-level JDBC batch size
See Also:
Since:5.2
/** * Set the Session-level JDBC batch size. * Overrides the SessionFactory JDBC batch size defined by the {@code hibernate.default_batch_fetch_size} configuration property for the scope of the current {@code Session}. * * @param jdbcBatchSize Session-level JDBC batch size * * @since 5.2 * * @see org.hibernate.boot.spi.SessionFactoryOptions#getJdbcBatchSize * @see org.hibernate.boot.SessionFactoryBuilder#applyJdbcBatchSize */
void setJdbcBatchSize(Integer jdbcBatchSize); }