Class StatelessSessionLazyDelegator
- All Implemented Interfaces:
Serializable, AutoCloseable, QueryProducer, SharedSessionContract, StatelessSession
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBegin a unit of work and return the associatedTransactionobject.voidclose()End the session by releasing the JDBC connection and cleaning up.<T> RootGraph<T> createEntityGraph(Class<T> rootType) Create a new mutable instance ofEntityGraph, with only a root node, allowing programmatic definition of the graph from scratch.<T> RootGraph<T> createEntityGraph(Class<T> rootType, String graphName) Create a new mutable instance ofEntityGraph, based on a predefined named entity graph, allowing customization of the graph, or returnnullif there is no predefined graph with the given name.RootGraph<?> createEntityGraph(String graphName) Create a new mutable instance ofEntityGraph, based on a predefined named entity graph, allowing customization of the graph, or returnnullif there is no predefined graph with the given name.createMutationQuery(CriteriaDelete deleteQuery) Create aMutationQueryfrom the given delete criteria treecreateMutationQuery(CriteriaUpdate updateQuery) Create aMutationQueryfrom the given update criteria treecreateMutationQuery(String hqlString) Create aMutationQueryreference for the given HQL insert, update, or delete statement.createMutationQuery(JpaCriteriaInsert insert) Create aMutationQueryfrom the given insert criteria treeCreate aMutationQueryinstance for the given named insert, update, or delete HQL query.createNamedQuery(String name) Deprecated.<R> Query<R> createNamedQuery(String name, Class<R> resultClass) Create a typedQueryinstance for the given named query.Deprecated.<R> SelectionQuery<R> createNamedSelectionQuery(String name, Class<R> resultType) Create aSelectionQueryinstance for the namedNamedQuerywith the given result type.Obtain aProcedureCallbased on a named templatecreateNativeMutationQuery(String sqlString) Create aNativeQueryinstance for the given native SQL statement.createNativeQuery(String sqlString) Deprecated.<R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass) Create aNativeQueryinstance for the given native SQL query using an implicit mapping to the specified Java type.<R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass, String tableAlias) Create aNativeQueryinstance for the given native SQL query using an implicit mapping to the specified Java entity type.createNativeQuery(String sqlString, String resultSetMappingName) Deprecated.<R> NativeQuery<R> createNativeQuery(String sqlString, String resultSetMappingName, Class<R> resultClass) Create aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.createQuery(CriteriaDelete deleteQuery) Deprecated.<R> Query<R> createQuery(CriteriaQuery<R> criteriaQuery) Create aQueryfor the given JPACriteriaQuery.createQuery(CriteriaUpdate updateQuery) Deprecated.<R> Query<R> createQuery(TypedQueryReference<R> typedQueryReference) Create a typedQueryinstance for the given typed query reference.createQuery(String queryString) Deprecated.<R> Query<R> createQuery(String queryString, Class<R> resultClass) Create a typedQueryinstance for the given HQL query string and given query result type.<R> SelectionQuery<R> createSelectionQuery(CriteriaQuery<R> criteria) Create aSelectionQueryreference for the givenCriteriaQuery.createSelectionQuery(String hqlString) Deprecated.<R> SelectionQuery<R> createSelectionQuery(String hqlString, EntityGraph<R> resultGraph) Create aSelectionQueryinstance for the given HQL query string and givenEntityGraph, which is interpreted as a load graph.<R> SelectionQuery<R> createSelectionQuery(String hqlString, Class<R> resultType) Create aSelectionQueryinstance for the given HQL query string and given query result type.createStoredProcedureCall(String procedureName) Create aProcedureCallto a stored procedure.createStoredProcedureCall(String procedureName, Class<?>... resultClasses) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureCall(String procedureName, String... resultSetMappings) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureQuery(String procedureName) Create aProcedureCallto a stored procedure.createStoredProcedureQuery(String procedureName, Class<?>... resultClasses) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureQuery(String procedureName, String... resultSetMappings) Create aProcedureCallto a stored procedure with the given result set entity mappings.abstract StatelessSessiondelegate()voidDelete a record.voidDelete a record.voiddeleteMultiple(List<?> entities) Delete multiple records in the same order as the entity instances representing the records occur in the given list.voiddisableFilter(String filterName) Disable the named filter for the current session.<T> TdoReturningWork(ReturningWork<T> work) Perform work using theConnectionunderlying by this session, and return a result.voidPerform work using theConnectionunderlying by this session.enableFilter(String filterName) Enable the named filter for this current session.voidFetch an association or collection that's configured for lazy loading.<T> Tget(EntityGraph<T> graph, Object id) Retrieve a record, fetching associations specified by the givenEntityGraph, which is interpreted as a load graph.<T> Tget(EntityGraph<T> graph, Object id, LockMode lockMode) Retrieve a record, fetching associations specified by the givenEntityGraph, which is interpreted as a load graph, and obtaining the specified lock mode.<T> Tget(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id) Retrieve a record, fetching associations specified by the givenEntityGraph.<T> Tget(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id, LockMode lockMode) Retrieve a record, fetching associations specified by the givenEntityGraph, and obtaining the specified lock mode.<T> TRetrieve a record.<T> TRetrieve a record, obtaining the specified lock mode.Retrieve a record.Retrieve a record, obtaining the specified lock mode.Get the current cache mode for this session.getEnabledFilter(String filterName) Retrieve a currently enabled filter by name.RootGraph<?> getEntityGraph(String graphName) Obtain an immutable reference to a predefined named entity graph.<T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) Retrieve all namedEntityGraphs with the given root entity type.The factory which created this session.getIdentifier(Object entity) Return the identifier value of the given entity, which may be detached.Get the session-level JDBC batch size for the current session.<T> List<T> getMultiple(EntityGraph<T> entityGraph, List<?> ids) Retrieve multiple rows, returning instances of the root entity of the givenEntityGraphwith the fetched associations specified by the graph, in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.<T> List<T> getMultiple(EntityGraph<T> entityGraph, GraphSemantic graphSemantic, List<?> ids) Retrieve multiple rows, returning instances of the root entity of the givenEntityGraphwith the fetched associations specified by the graph, in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.<T> List<T> getMultiple(Class<T> entityClass, List<?> ids) Retrieve multiple rows, returning entity instances in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.<T> List<T> getMultiple(Class<T> entityClass, List<?> ids, LockMode lockMode) Retrieve multiple rows, obtaining the specified lock mode, and returning entity instances in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.getNamedNativeQuery(String name) Deprecated.getNamedNativeQuery(String name, String resultSetMapping) Deprecated.getNamedProcedureCall(String name) Obtain aProcedureCallbased on a named templategetNamedQuery(String queryName) Deprecated.Obtain the tenant identifier associated with this session, as a string.Obtain the tenant identifier associated with this session.Get theTransactioninstance associated with this session.Insert a record.Insert a record.voidinsertMultiple(List<?> entities) Insert multiple records in the same order as the entity instances representing the new records occur in the given list.booleanCheck if the session is currently connected.booleanCheck if the session is joined to the current transaction.booleanisOpen()Check if the session is still open.voidJoin the currently-active JTA transaction.voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.Obtain aSessionbuilder with the ability to copy certain information from this session.voidsetCacheMode(CacheMode cacheMode) Set the current cache mode for this session.voidsetJdbcBatchSize(Integer jdbcBatchSize) Set the session-level JDBC batch size.Obtain aStatelessSessionbuilder with the ability to copy certain information from this session.<T> TReturn an object of the specified type to allow access to a provider-specific API.voidUpdate a record.voidUpdate a record.voidupdateMultiple(List<?> entities) Update multiple records in the same order as the entity instances representing the records occur in the given list.voidUse a SQLmerge intostatement to perform an upsert, that is, to insert the record if it does not exist, or update it if it already exists.voidUse a SQLmerge intostatement to perform an upsert.voidupsertMultiple(List<?> entities) Upsert multiple records, that is, for a given record, insert the record if it does not exist or update the record if it already exists, in the same order as the entity instances representing the records occur in the given list.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SharedSessionContract
fromTransaction, inTransaction
-
Constructor Details
-
StatelessSessionLazyDelegator
public StatelessSessionLazyDelegator()
-
-
Method Details
-
delegate
-
delete
Description copied from interface:StatelessSessionDelete a record.The
PostRemovecallback will be triggered if the operation is successful.- Specified by:
deletein interfaceStatelessSession- Parameters:
entity- a detached entity instance
-
insert
Description copied from interface:StatelessSessionInsert a record.If the entity
@Idfield is declared to be generated, for example, if it is annotated@GeneratedValue, the id is generated and assigned to the given instance.The
PostPersistcallback will be triggered if the operation is successful.- Specified by:
insertin interfaceStatelessSession- Parameters:
entity- a new transient instance- Returns:
- The identifier of the inserted entity
-
insertMultiple
Description copied from interface:StatelessSessionInsert multiple records in the same order as the entity instances representing the new records occur in the given list.- Specified by:
insertMultiplein interfaceStatelessSession- Parameters:
entities- a list of transient instances to be inserted
-
insert
Description copied from interface:StatelessSessionInsert a record.The
PostPersistcallback will be triggered if the operation is successful.- Specified by:
insertin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be insertedentity- a new transient instance- Returns:
- the identifier of the instance
-
update
Description copied from interface:StatelessSessionUpdate a record.The
PostUpdatecallback will be triggered if the operation is successful.- Specified by:
updatein interfaceStatelessSession- Parameters:
entity- a detached entity instance
-
updateMultiple
Description copied from interface:StatelessSessionUpdate multiple records in the same order as the entity instances representing the records occur in the given list.- Specified by:
updateMultiplein interfaceStatelessSession- Parameters:
entities- a list of detached instances to be updated
-
update
Description copied from interface:StatelessSessionUpdate a record.The
PostUpdatecallback will be triggered if the operation is successful.- Specified by:
updatein interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be updatedentity- a detached entity instance
-
deleteMultiple
Description copied from interface:StatelessSessionDelete multiple records in the same order as the entity instances representing the records occur in the given list.- Specified by:
deleteMultiplein interfaceStatelessSession- Parameters:
entities- a list of detached instances to be deleted
-
delete
Description copied from interface:StatelessSessionDelete a record.The
PostRemovecallback will be triggered if the operation is successful.- Specified by:
deletein interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be deletedentity- a detached entity instance
-
upsert
Description copied from interface:StatelessSessionUse a SQLmerge intostatement to perform an upsert, that is, to insert the record if it does not exist, or update it if it already exists.This method never performs id generation, and does not accept an entity instance with a null identifier. When id generation is required, use
StatelessSession.insert(Object).On the other hand,
upsert()does accept an entity instance with an assigned identifier value, even if the entity@Idfield is declared to be generated, for example, if it is annotated@GeneratedValue. Thus, this method may be used to import data from an external source.- Specified by:
upsertin interfaceStatelessSession- Parameters:
entity- a detached entity instance, or a new instance with an assigned identifier
-
upsertMultiple
Description copied from interface:StatelessSessionUpsert multiple records, that is, for a given record, insert the record if it does not exist or update the record if it already exists, in the same order as the entity instances representing the records occur in the given list.- Specified by:
upsertMultiplein interfaceStatelessSession- Parameters:
entities- a list of detached instances and new instances with assigned identifiers
-
upsert
Description copied from interface:StatelessSessionUse a SQLmerge intostatement to perform an upsert.- Specified by:
upsertin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be mergedentity- a detached entity instance
-
get
Description copied from interface:StatelessSessionRetrieve a record.- Specified by:
getin interfaceStatelessSession- Parameters:
entityName- The name of the entity to retrieveid- The id of the entity to retrieve- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
get
Description copied from interface:StatelessSessionRetrieve a record.- Specified by:
getin interfaceStatelessSession- Parameters:
entityClass- The class of the entity to retrieveid- The id of the entity to retrieve- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
get
Description copied from interface:StatelessSessionRetrieve a record, obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Parameters:
entityName- The name of the entity to retrieveid- The id of the entity to retrievelockMode- The lock mode to apply to the entity- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
get
Description copied from interface:StatelessSessionRetrieve a record, obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Parameters:
entityClass- The class of the entity to retrieveid- The id of the entity to retrievelockMode- The lock mode to apply to the entity- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
get
Description copied from interface:StatelessSessionRetrieve a record, fetching associations specified by the givenEntityGraph, which is interpreted as a load graph.- Specified by:
getin interfaceStatelessSession- Parameters:
graph- TheEntityGraph, interpreted as a load graphid- The id of the entity to retrieve- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
get
Description copied from interface:StatelessSessionRetrieve a record, fetching associations specified by the givenEntityGraph, which is interpreted as a load graph, and obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Parameters:
graph- TheEntityGraph, interpreted as a load graphid- The id of the entity to retrievelockMode- The lock mode to apply to the entity- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
get
Description copied from interface:StatelessSessionRetrieve a record, fetching associations specified by the givenEntityGraph.- Specified by:
getin interfaceStatelessSession- Parameters:
graph- TheEntityGraphgraphSemantic- aGraphSemanticspecifying how the graph should be interpretedid- The id of the entity to retrieve- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
get
Description copied from interface:StatelessSessionRetrieve a record, fetching associations specified by the givenEntityGraph, and obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Parameters:
graph- TheEntityGraphgraphSemantic- aGraphSemanticspecifying how the graph should be interpretedid- The id of the entity to retrievelockMode- The lock mode to apply to the entity- Returns:
- a detached entity instance, or null if there is no instance with the given id
-
getMultiple
Description copied from interface:StatelessSessionRetrieve multiple rows, returning entity instances in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.- Specified by:
getMultiplein interfaceStatelessSession- Parameters:
entityClass- The class of the entity to retrieveids- The ids of the entities to retrieve- Returns:
- an ordered list of detached entity instances, with null elements representing missing entities
-
getMultiple
Description copied from interface:StatelessSessionRetrieve multiple rows, obtaining the specified lock mode, and returning entity instances in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.- Specified by:
getMultiplein interfaceStatelessSession- Parameters:
entityClass- The class of the entity to retrieveids- The ids of the entities to retrievelockMode- The lock mode to apply to the entities- Returns:
- an ordered list of detached entity instances, with null elements representing missing entities
-
getMultiple
Description copied from interface:StatelessSessionRetrieve multiple rows, returning instances of the root entity of the givenEntityGraphwith the fetched associations specified by the graph, in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.- Specified by:
getMultiplein interfaceStatelessSession- Parameters:
entityGraph- TheEntityGraph, interpreted as a load graphids- The ids of the entities to retrieve- Returns:
- an ordered list of detached entity instances, with null elements representing missing entities
-
getMultiple
public <T> List<T> getMultiple(EntityGraph<T> entityGraph, GraphSemantic graphSemantic, List<?> ids) Description copied from interface:StatelessSessionRetrieve multiple rows, returning instances of the root entity of the givenEntityGraphwith the fetched associations specified by the graph, in a list where the position of an instance in the list matches the position of its identifier in the given array, and the list contains a null value if there is no persistent instance matching a given identifier.- Specified by:
getMultiplein interfaceStatelessSession- Parameters:
entityGraph- TheEntityGraphgraphSemantic- aGraphSemanticspecifying how the graph should be interpretedids- The ids of the entities to retrieve- Returns:
- an ordered list of detached entity instances, with null elements representing missing entities
-
refresh
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entity- The entity to be refreshed.
-
refresh
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be refreshed.entity- The entity to be refreshed.
-
refresh
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entity- The entity to be refreshed.lockMode- The LockMode to be applied.
-
refresh
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be refreshed.entity- The entity to be refreshed.lockMode- The LockMode to be applied.
-
fetch
Description copied from interface:StatelessSessionFetch an association or collection that's configured for lazy loading.Book book = session.get(Book.class, isbn); // book is immediately detached session.fetch(book.getAuthors()); // fetch the associated authors book.getAuthors().forEach(author -> ... ); // iterate the collection
Warning: this operation in a stateless session is quite sensitive to data aliasing effects and should be used with great care. It's usually better to fetch associations using eager join fetching.
- Specified by:
fetchin interfaceStatelessSession- Parameters:
association- a lazy-loaded association- See Also:
-
getIdentifier
Description copied from interface:StatelessSessionReturn the identifier value of the given entity, which may be detached.- Specified by:
getIdentifierin interfaceStatelessSession- Parameters:
entity- a persistent instance associated with this session- Returns:
- the identifier
-
statelessWithOptions
Description copied from interface:SharedSessionContractObtain aStatelessSessionbuilder with the ability to copy certain information from this session.- Specified by:
statelessWithOptionsin interfaceSharedSessionContract- Returns:
- the session builder
-
sessionWithOptions
Description copied from interface:SharedSessionContractObtain aSessionbuilder with the ability to copy certain information from this session.- Specified by:
sessionWithOptionsin interfaceSharedSessionContract- Returns:
- the session builder
-
getTenantIdentifier
Description copied from interface:SharedSessionContractObtain the tenant identifier associated with this session, as a string.- Specified by:
getTenantIdentifierin interfaceSharedSessionContract- Returns:
- The tenant identifier associated with this session, or
null - See Also:
-
getTenantIdentifierValue
Description copied from interface:SharedSessionContractObtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifierValuein interfaceSharedSessionContract- Returns:
- The tenant identifier associated with this session, or
null - See Also:
-
getCacheMode
Description copied from interface:SharedSessionContractGet the current cache mode for this session.- Specified by:
getCacheModein interfaceSharedSessionContract- Returns:
- the current cache mode
-
setCacheMode
Description copied from interface:SharedSessionContractSet the current cache mode for this session.The cache mode determines the manner in which this session can interact with the second level cache.
- Specified by:
setCacheModein interfaceSharedSessionContract- Parameters:
cacheMode- the new cache mode
-
close
Description copied from interface:SharedSessionContractEnd the session by releasing the JDBC connection and cleaning up.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSharedSessionContract- Throws:
HibernateException- Indicates problems cleaning up.
-
isOpen
public boolean isOpen()Description copied from interface:SharedSessionContractCheck if the session is still open.- Specified by:
isOpenin interfaceSharedSessionContract- Returns:
trueif it is open
-
isConnected
public boolean isConnected()Description copied from interface:SharedSessionContractCheck if the session is currently connected.- Specified by:
isConnectedin interfaceSharedSessionContract- Returns:
trueif it is connected
-
beginTransaction
Description copied from interface:SharedSessionContractBegin a unit of work and return the associatedTransactionobject. If a new underlying transaction is required, begin the transaction. Otherwise, continue the new work in the context of the existing underlying transaction.- Specified by:
beginTransactionin interfaceSharedSessionContract- Returns:
- an instance of
Transactionrepresenting the new transaction - See Also:
-
getTransaction
Description copied from interface:SharedSessionContractGet theTransactioninstance associated with this session.- Specified by:
getTransactionin interfaceSharedSessionContract- Returns:
- an instance of
Transactionrepresenting the transaction associated with this session - See Also:
-
joinTransaction
public void joinTransaction()Description copied from interface:SharedSessionContractJoin the currently-active JTA transaction.- Specified by:
joinTransactionin interfaceSharedSessionContract- See Also:
-
isJoinedToTransaction
public boolean isJoinedToTransaction()Description copied from interface:SharedSessionContractCheck if the session is joined to the current transaction.- Specified by:
isJoinedToTransactionin interfaceSharedSessionContract- See Also:
-
getNamedProcedureCall
Description copied from interface:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
getNamedProcedureCallin interfaceSharedSessionContract- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
-
createStoredProcedureCall
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultClasses- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Parameters:
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.
-
createNamedStoredProcedureQuery
Description copied from interface:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
createNamedStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultClasses- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
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.
-
getJdbcBatchSize
Description copied from interface:SharedSessionContractGet the session-level JDBC batch size for the current session.- Specified by:
getJdbcBatchSizein interfaceSharedSessionContract- Returns:
- the current session-level JDBC batch size
- See Also:
-
setJdbcBatchSize
Description copied from interface:SharedSessionContractSet the session-level JDBC batch size. Override the factory-level JDBC batch size controlled by the configuration property "hibernate.jdbc.batch_size".- Specified by:
setJdbcBatchSizein interfaceSharedSessionContract- Parameters:
jdbcBatchSize- the new session-level JDBC batch size- See Also:
-
getCriteriaBuilder
Description copied from interface:SharedSessionContract- Specified by:
getCriteriaBuilderin interfaceSharedSessionContract- Returns:
- an instance of
HibernateCriteriaBuilder - See Also:
-
doWork
Description copied from interface:SharedSessionContractPerform work using theConnectionunderlying by this session.- Specified by:
doWorkin interfaceSharedSessionContract- Parameters:
work- The work to be performed.- Throws:
HibernateException- Generally indicates wrappedSQLException
-
doReturningWork
Description copied from interface:SharedSessionContractPerform work using theConnectionunderlying by this session, and return a result.- Specified by:
doReturningWorkin interfaceSharedSessionContract- Type Parameters:
T- The type of the result returned from the work- Parameters:
work- The work to be performed.- Returns:
- the result of calling
ReturningWork.execute(Connection).
-
createEntityGraph
Description copied from interface:SharedSessionContractCreate a new mutable instance ofEntityGraph, with only a root node, allowing programmatic definition of the graph from scratch.- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
rootType- the root entity class of the graph- See Also:
-
createEntityGraph
Description copied from interface:SharedSessionContractCreate a new mutable instance ofEntityGraph, based on a predefined named entity graph, allowing customization of the graph, or returnnullif there is no predefined graph with the given name.- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
graphName- the name of the graph- See Also:
-
createEntityGraph
Description copied from interface:SharedSessionContractCreate a new mutable instance ofEntityGraph, based on a predefined named entity graph, allowing customization of the graph, or returnnullif there is no predefined graph with the given name.- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
rootType- the root entity class of the graphgraphName- the name of the predefined named entity graph- See Also:
-
getEntityGraph
Description copied from interface:SharedSessionContractObtain an immutable reference to a predefined named entity graph.- Specified by:
getEntityGraphin interfaceSharedSessionContract- Parameters:
graphName- the name of the predefined named entity graph- See Also:
-
getEntityGraphs
Description copied from interface:SharedSessionContractRetrieve all namedEntityGraphs with the given root entity type.- Specified by:
getEntityGraphsin interfaceSharedSessionContract- See Also:
-
enableFilter
Description copied from interface:SharedSessionContractEnable the named filter for this current session.The returned
Filterobject must be used to bind arguments to parameters of the filter, and every parameter must be set before any other operation of this session is called.- Specified by:
enableFilterin interfaceSharedSessionContract- Parameters:
filterName- the name of the filter to be enabled.- Returns:
- the
Filterinstance representing the enabled filter. - See Also:
-
getEnabledFilter
Description copied from interface:SharedSessionContractRetrieve a currently enabled filter by name.- Specified by:
getEnabledFilterin interfaceSharedSessionContract- Parameters:
filterName- the name of the filter to be retrieved.- Returns:
- the
Filterinstance representing the enabled filter.
-
disableFilter
Description copied from interface:SharedSessionContractDisable the named filter for the current session.- Specified by:
disableFilterin interfaceSharedSessionContract- Parameters:
filterName- the name of the filter to be disabled.
-
getFactory
Description copied from interface:SharedSessionContractThe factory which created this session.- Specified by:
getFactoryin interfaceSharedSessionContract
-
createQuery
Deprecated.Description copied from interface:QueryProducerCreate aQueryinstance for the given HQL query, or HQL insert, update, or delete statement.If a query has no explicit
selectlist, the select list is inferred:- if there is exactly one root entity in the
fromclause, and it has no non-fetchjoins, then that root entity is the only element of the select list, or - if there is an entity with the alias
this, then that entity is the only element of the select list, or - otherwise, the query is considered ambiguous, and this
method throws a
SemanticException.
The query must have an explicit
fromclause, which can never be inferred.- Specified by:
createQueryin interfaceQueryProducer- Parameters:
queryString- The HQL query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
- if there is exactly one root entity in the
-
createQuery
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given HQL query string and given query result type.- If the query has a single item in the
selectlist, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[],List,Map, orTuple.
If a query has no explicit
selectlist, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
fromclause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetchjoined entity, and each query result will be packaged into an instance of the result type, just as specified above.
If a query has no explicit
fromclause, and the given result type is an entity type, the root entity is inferred to be the result type.Passing
Object.classas the query result type is not recommended. In this special case, this method has the same semantics as the overloadQueryProducer.createQuery(String).The returned
Querymay be executed by callingQuery.getResultList()orQuery.getSingleResult().- Specified by:
createQueryin interfaceQueryProducer- Parameters:
queryString- The HQL queryresultClass- TheClassobject representing the query result type, which should not beObject.class- Returns:
- The
Queryinstance for manipulation and execution - See Also:
- If the query has a single item in the
-
createQuery
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given typed query reference.- Specified by:
createQueryin interfaceQueryProducer- Parameters:
typedQueryReference- the type query reference- Returns:
- The
Queryinstance for execution - See Also:
-
createQuery
Description copied from interface:QueryProducerCreate aQueryfor the given JPACriteriaQuery.- Specified by:
createQueryin interfaceQueryProducer
-
createQuery
Deprecated.Description copied from interface:QueryProducerCreate aMutationQueryfor the given JPACriteriaUpdate- Specified by:
createQueryin interfaceQueryProducer
-
createQuery
Deprecated.Description copied from interface:QueryProducerCreate aMutationQueryfor the given JPACriteriaDelete- Specified by:
createQueryin interfaceQueryProducer
-
createNativeQuery
Deprecated.Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query.- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- a native SQL query string- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
-
createNativeQuery
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an implicit mapping to the specified Java type.- If the given class is an entity class, this method is equivalent
to
createNativeQuery(sqlString).addEntity(resultClass). - If the given class has a registered
JavaType, then the query must return a result set with a single column whoseJdbcTypeis compatible with thatJavaType. - Otherwise, the select items will be packaged into an instance of
the result type. The result type must have an appropriate
constructor with parameter types matching the select items, or it
must be one of the types
Object[],List,Map, orTuple.
- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- The native (SQL) query stringresultClass- The Java type to map results to- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
- If the given class is an entity class, this method is equivalent
to
-
createNativeQuery
public <R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass, String tableAlias) Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an implicit mapping to the specified Java entity type.The given class must be an entity class. This method is equivalent to
createNativeQuery(sqlString).addEntity(tableAlias, resultClass).- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- Native (SQL) query stringresultClass- The Java entity class to map results totableAlias- The table alias for columns in the result set- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
-
createNativeQuery
Deprecated.Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMappingannotation.- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- The native (SQL) query stringresultSetMappingName- The explicit result mapping name- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
-
createNativeQuery
public <R> NativeQuery<R> createNativeQuery(String sqlString, String resultSetMappingName, Class<R> resultClass) Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMappingannotation.- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- The native (SQL) query stringresultSetMappingName- The explicit result mapping name- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
-
createSelectionQuery
Deprecated.Description copied from interface:QueryProducerCreate aSelectionQueryreference for the given HQLselectstatement.If the statement has no explicit
selectlist, the select list is inferred:- if there is exactly one root entity in the
fromclause, and it has no non-fetchjoins, then that root entity is the only element of the select list, or - if there is an entity with the alias
this, then that entity is the only element of the select list, or - otherwise, the query is considered ambiguous, and this
method throws a
SemanticException.
The query must have an explicit
fromclause, which can never be inferred.- Specified by:
createSelectionQueryin interfaceQueryProducer
- if there is exactly one root entity in the
-
createSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the given HQL query string and given query result type.- If the query has a single item in the
selectlist, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[],List,Map, orTuple.
If a query has no explicit
selectlist, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
fromclause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetchjoined entity, and each query result will be packaged into an instance of the result type, just as specified above.
If a query has no explicit
fromclause, and the given result type is an entity type, the root entity is inferred to be the result type.Passing
Object.classas the query result type is not recommended. In this special case, this method has the same semantics as the overloadQueryProducer.createSelectionQuery(String).The returned
Querymay be executed by callingQuery.getResultList()orQuery.getSingleResult().- Specified by:
createSelectionQueryin interfaceQueryProducer- Parameters:
hqlString- The HQLselectquery as a stringresultType- TheClassobject representing the query result type, which should not beObject.class- See Also:
- If the query has a single item in the
-
createSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the given HQL query string and givenEntityGraph, which is interpreted as a load graph. The query result type is the root entity of the given graph.- If the query has an explicit
selectclause, there must be a single item in theselectlist, and the select item must be assignable to the root type of the given graph. - Otherwise, if a query has no explicit
selectlist, the select list is inferred from the given entity graph. The query must have exactly one root entity in thefromclause, it must be assignable to the root type of the given graph, and the inferred select list will contain just that entity.
If a query has no explicit
fromclause, and the given result type is an entity type, the root entity is inferred to be the result type.The returned
Querymay be executed by callingQuery.getResultList()orQuery.getSingleResult().- Specified by:
createSelectionQueryin interfaceQueryProducer- Parameters:
hqlString- The HQLselectquery as a stringresultGraph- AnEntityGraphwhose root type is the query result type, which is interpreted as a load graph- See Also:
- If the query has an explicit
-
createSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the givenCriteriaQuery.- Specified by:
createSelectionQueryin interfaceQueryProducer- See Also:
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryreference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQueryin interfaceQueryProducer- Parameters:
hqlString- The HQLinsert,update, ordeletestatement
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given update criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given delete criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given insert criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
createNativeMutationQuery
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL statement.- Specified by:
createNativeMutationQueryin interfaceQueryProducer- Parameters:
sqlString- a native SQL statement string- Returns:
- The NativeQuery instance for manipulation and execution
-
createNamedQuery
Deprecated.Description copied from interface:QueryProducerCreate a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQueryin interfaceQueryProducer- Parameters:
name- the name of a predefined named query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
-
createNamedQuery
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQueryin interfaceQueryProducer- Parameters:
name- the name of a query defined in metadataresultClass- the type of the query result- Returns:
- The
Queryinstance for manipulation and execution - See Also:
-
createNamedSelectionQuery
Deprecated.Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuery.- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
createNamedSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuerywith the given result type.- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
createNamedMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryinstance for the given named insert, update, or delete HQL query. The named query might be defined as HQL) or native-SQL.- Specified by:
createNamedMutationQueryin interfaceQueryProducer
-
getNamedQuery
Deprecated.Description copied from interface:QueryProducerCreate aQueryinstance for the named query.- Specified by:
getNamedQueryin interfaceQueryProducer- Parameters:
queryName- the name of a predefined named query- Returns:
- The
Queryinstance for manipulation and execution
-
getNamedNativeQuery
Deprecated.Description copied from interface:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Parameters:
name- The name of the predefined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
getNamedNativeQuery
Deprecated.Description copied from interface:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Parameters:
name- The name of the predefined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
unwrap
Description copied from interface:SharedSessionContractReturn an object of the specified type to allow access to a provider-specific API.- Specified by:
unwrapin interfaceSharedSessionContract- Parameters:
type- the class of the object to be returned. This is usually either the underlying class implementingSharedSessionContractor an interface it implements.- Returns:
- an instance of the specified class
-