Class StatelessSessionLazyDelegator
- All Implemented Interfaces:
EntityAgent, EntityHandler, Serializable, AutoCloseable, SharedSessionContract, StatelessSession
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface EntityAgent
EntityAgent.CreationOption, EntityAgent.Option -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddOption(EntityAgent.Option option) Begin a unit of work and return the associatedTransactionobject.<C,T> T callWithConnection(ConnectionFunction<C, T> function) 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) Deprecated, for removal: This API element is subject to removal in a future version.RootGraph<?> createEntityGraph(String graphName) Deprecated, for removal: This API element is subject to removal in a future version.createMutationQuery(CriteriaStatement<?> criteriaStatement) 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) Create an instance ofQueryfor the given named query or statement, without indicating the expected result type, if any, nor whether the query is a typed query which returns a result list, or an update, delete, or insert statement.<R> SelectionQuery<R> createNamedQuery(String name, Class<R> resultClass) Create a typedQueryinstance for the given named query.<R> NativeQuery<R> createNamedQuery(String name, String resultSetMappingName) <R> NativeQuery<R> createNamedQuery(String name, String resultSetMappingName, Class<R> resultClass) <R> SelectionQuery<R> createNamedSelectionQuery(String name, Class<R> resultType) Create aSelectionQueryinstance for the namedNamedQuerywith the given result type.createNamedStatement(String name) Obtain aProcedureCallbased on a named templatecreateNativeMutationQuery(String sqlString) Create aNativeQueryinstance for the given native SQL statement.NativeQuery<?> createNativeQuery(String sqlString) Create aNativeQueryinstance for the given native SQL query.<T> TypedQuery<T> createNativeQuery(String sql, jakarta.persistence.sql.ResultSetMapping<T> resultSetMapping) <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.NativeQuery<?> createNativeQuery(String sql, String resultSetMapping) <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.<T> SelectionQuery<T> createQuery(CriteriaSelect<T> criteriaSelect) <R> SelectionQuery<R> createQuery(TypedQueryReference<R> typedQueryReference) Create a typedQueryinstance for the given typed query reference.createQuery(String queryString) Create an instance ofQueryfor the given HQL query or statement, without indicating the expected result type, if any, nor whether the query is a typed query which returns a result list, or an update, delete, or insert statement.<T> SelectionQuery<T> createQuery(String hqlString, EntityGraph<T> entityGraph) <R> SelectionQuery<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.<R> SelectionQuery<R> createSelectionQuery(CriteriaSelect<R> criteria) Create aSelectionQueryreference for the givenCriteriaQuery.<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.createStatement(CriteriaStatement<?> criteriaStatement) createStatement(StatementReference statementReference) createStatement(String hqlString) 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.<T> Tfetch(T association) Fetch an association or collection that's configured for lazy loading.<T> Tfind(EntityGraph<T> entityGraph, Object primaryKey, FindOption... options) <T> T<T> Tfind(Class<T> entityClass, Object primaryKey, FindOption... options) find(String entityName, Object key, FindOption... findOptions) Corollary toEntityHandler.find(Class,Object,FindOption...)for dynamic models.<E> List<E> findMultiple(EntityGraph<E> entityGraph, List<?> ids, FindOption... options) <E> List<E> findMultiple(Class<E> entityType, List<?> ids, FindOption... options) <T> Tget(EntityGraph<T> entityGraph, Object key, FindOption... findOptions) <T> Tget(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id) Deprecated, for removal: This API element is subject to removal in a future version.<T> Tget(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id, LockMode lockMode) Deprecated, for removal: This API element is subject to removal in a future version.<T> T<T> Tget(Class<T> entityType, Object key, FindOption... findOptions) get(String entityName, Object key, FindOption... findOptions) Form ofSharedSessionContract.find(String,Object,FindOption...)throwingEntityNotFoundExceptionif no entity exists for that id rather than returning null.Deprecated, for removal: This API element is subject to removal in a future version.Get the current cache mode for this session.getEnabledFilter(String filterName) Retrieve a currently enabled filter by name.<T> RootGraph<T> getEntityGraph(Class<T> rootType, String graphName) Obtain a mutable copy of a predefined named entity graph whose root type is exactly the given entity type.RootGraph<?> getEntityGraph(String graphName) Obtain a mutable copy of 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<?> keys, FindOption... findOptions) <T> List<T> getMultiple(EntityGraph<T> entityGraph, GraphSemantic graphSemantic, List<?> ids) Deprecated, for removal: This API element is subject to removal in a future version.<T> List<T> getMultiple(Class<T> entityType, List<?> keys, FindOption... findOptions) getNamedProcedureCall(String name) Obtain aProcedureCallbased on a named templateObtain the tenant identifier associated with this session, as a string.Obtain the tenant identifier associated with this session.Get theTransactioninstance associated with this session.voidInsert 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(Object entity, LockModeType lockModeType) voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidrefreshMultiple(List<?> entities) <C> voidrunWithConnection(ConnectionConsumer<C> action) Obtain aSessionbuilder with the ability to copy certain information from this session.voidsetCacheMode(CacheMode cacheMode) Set the current cache mode for this session.voidsetCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) voidsetCacheStoreMode(CacheStoreMode cacheStoreMode) voidsetJdbcBatchSize(Integer jdbcBatchSize) Set the session-level JDBC batch size.voidsetProperty(String propertyName, Object value) Obtain aStatelessSessionbuilder with the ability to copy certain information from this session.<T> TvoidUpdate 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
createNativeQuery, createQuery, find, fromTransaction, get, inTransaction
-
Constructor Details
-
StatelessSessionLazyDelegator
public StatelessSessionLazyDelegator()
-
-
Method Details
-
delegate
-
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 interfaceEntityAgent- Specified by:
insertin interfaceStatelessSession- Parameters:
entity- a new transient instance
-
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 interfaceEntityAgent- 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 interfaceEntityAgent- 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 interfaceEntityAgent- 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
-
delete
Description copied from interface:StatelessSessionDelete a record.The
PostRemovecallback will be triggered if the operation is successful.- Specified by:
deletein interfaceEntityAgent- Specified by:
deletein interfaceStatelessSession- Parameters:
entity- 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 interfaceEntityAgent- 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 entity name 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 interfaceEntityAgent- 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 interfaceEntityAgent- 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 entity name for the entity to be mergedentity- a detached entity instance
-
get
@Deprecated(forRemoval=true, since="8.0") @Nonnull public Object get(@Nonnull String entityName, @Nonnull Object id, @Nonnull LockMode lockMode) Deprecated, for removal: This API element is subject to removal in a future version.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
@Deprecated(forRemoval=true, since="8.0") @Nonnull public <T> T get(@Nonnull EntityGraph<T> graph, @Nonnull GraphSemantic graphSemantic, @Nonnull Object id) Deprecated, for removal: This API element is subject to removal in a future version.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
@Deprecated(forRemoval=true, since="8.0") @Nonnull public <T> T get(@Nonnull EntityGraph<T> graph, @Nonnull GraphSemantic graphSemantic, @Nonnull Object id, @Nonnull LockMode lockMode) Deprecated, for removal: This API element is subject to removal in a future version.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
@Deprecated(forRemoval=true, since="8.0") @Nonnull public <T> List<T> getMultiple(@Nonnull EntityGraph<T> entityGraph, @Nonnull GraphSemantic graphSemantic, @Nonnull List<?> ids) Deprecated, for removal: This API element is subject to removal in a future version.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 interfaceEntityAgent- 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 entity name 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 entity name for the entity to be refreshed.entity- The entity to be refreshed.lockMode- The LockMode to be applied.
-
refresh
- Specified by:
refreshin interfaceEntityAgent
-
refreshMultiple
- Specified by:
refreshMultiplein interfaceEntityAgent
-
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 interfaceEntityAgent- 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
-
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
-
setCacheRetrieveMode
- Specified by:
setCacheRetrieveModein interfaceEntityHandler
-
setCacheStoreMode
- Specified by:
setCacheStoreModein interfaceEntityHandler
-
getCacheStoreMode
- Specified by:
getCacheStoreModein interfaceEntityHandler
-
getCacheRetrieveMode
- Specified by:
getCacheRetrieveModein interfaceEntityHandler
-
addOption
- Specified by:
addOptionin interfaceEntityAgent
-
getOptions
- Specified by:
getOptionsin interfaceEntityAgent
-
close
public void close()Description copied from interface:SharedSessionContractEnd the session by releasing the JDBC connection and cleaning up.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceEntityHandler- Specified by:
closein interfaceSharedSessionContract
-
isOpen
public boolean isOpen()Description copied from interface:SharedSessionContractCheck if the session is still open.- Specified by:
isOpenin interfaceEntityHandler- 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 interfaceEntityHandler- 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:
-
find
@Nullable public Object find(@Nonnull String entityName, @Nonnull Object key, @Nullable FindOption... findOptions) Description copied from interface:SharedSessionContractCorollary toEntityHandler.find(Class,Object,FindOption...)for dynamic models.- Specified by:
findin interfaceSharedSessionContract- Parameters:
entityName- The entity namekey- The key (primary or natural, based onKeyType)findOptions- Options for the load operation.- Returns:
- The persistent instance, or null
- See Also:
-
get
@Nonnull public Object get(@Nonnull String entityName, @Nonnull Object key, @Nullable FindOption... findOptions) Description copied from interface:SharedSessionContractForm ofSharedSessionContract.find(String,Object,FindOption...)throwingEntityNotFoundExceptionif no entity exists for that id rather than returning null.- Specified by:
getin interfaceSharedSessionContract- Parameters:
entityName- The entity namekey- The key (primary or natural, based onKeyType)findOptions- Options for the load operation.- Returns:
- a persistent instance
- See Also:
-
findMultiple
@Nonnull public <E> List<E> findMultiple(@Nonnull Class<E> entityType, @Nonnull List<?> ids, @Nullable FindOption... options) - Specified by:
findMultiplein interfaceEntityHandler
-
findMultiple
@Nonnull public <E> List<E> findMultiple(@Nonnull EntityGraph<E> entityGraph, @Nonnull List<?> ids, @Nullable FindOption... options) - Specified by:
findMultiplein interfaceEntityHandler
-
find
-
find
@Nullable public <T> T find(@Nonnull Class<T> entityClass, @Nonnull Object primaryKey, @Nullable FindOption... options) - Specified by:
findin interfaceEntityHandler
-
find
@Nullable public <T> T find(@Nonnull EntityGraph<T> entityGraph, @Nonnull Object primaryKey, @Nullable FindOption... options) - Specified by:
findin interfaceEntityHandler
-
get
-
get
@Nonnull public <T> T get(@Nonnull Class<T> entityType, @Nonnull Object key, @Nullable FindOption... findOptions) - Specified by:
getin interfaceEntityHandler
-
get
@Nonnull public <T> T get(@Nonnull EntityGraph<T> entityGraph, @Nonnull Object key, @Nullable FindOption... findOptions) - Specified by:
getin interfaceEntityHandler
-
getMultiple
@Nonnull public <T> List<T> getMultiple(@Nonnull Class<T> entityType, @Nonnull List<?> keys, @Nullable FindOption... findOptions) - Specified by:
getMultiplein interfaceEntityHandler
-
getMultiple
@Nonnull public <T> List<T> getMultiple(@Nonnull EntityGraph<T> entityGraph, @Nonnull List<?> keys, @Nullable FindOption... findOptions) - Specified by:
getMultiplein interfaceEntityHandler
-
createQuery
@Nonnull public <R> SelectionQuery<R> createQuery(@Nonnull String queryString, @Nonnull Class<R> resultClass) Description copied from interface:SharedSessionContractCreate 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.The returned
Querymay be executed by callingSelectionQuery.getResultList()orSelectionQuery.getSingleResult().- Specified by:
createQueryin interfaceEntityHandler- Specified by:
createQueryin interfaceSharedSessionContract- 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
@Nonnull public <T> SelectionQuery<T> createQuery(@Nonnull String hqlString, @Nonnull EntityGraph<T> entityGraph) - Specified by:
createQueryin interfaceEntityHandler- Specified by:
createQueryin interfaceSharedSessionContract- See Also:
-
createSelectionQuery
Description copied from interface:SharedSessionContractCreate 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.The returned
Querymay be executed by callingSelectionQuery.getResultList()orSelectionQuery.getSingleResult().- Specified by:
createSelectionQueryin interfaceSharedSessionContract- 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:SharedSessionContractCreate 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 callingSelectionQuery.getResultList()orSelectionQuery.getSingleResult().- Specified by:
createSelectionQueryin interfaceSharedSessionContract- 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
-
createMutationQuery
Description copied from interface:SharedSessionContractCreate aMutationQueryreference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQueryin interfaceSharedSessionContract- Parameters:
hqlString- The HQLinsert,update, ordeletestatement
-
createStatement
- Specified by:
createStatementin interfaceEntityHandler- Specified by:
createStatementin interfaceSharedSessionContract
-
createStatement
- Specified by:
createStatementin interfaceEntityHandler- Specified by:
createStatementin interfaceSharedSessionContract
-
createQuery
@Nonnull public <R> SelectionQuery<R> createQuery(@Nonnull TypedQueryReference<R> typedQueryReference) Description copied from interface:SharedSessionContractCreate a typedQueryinstance for the given typed query reference.- Specified by:
createQueryin interfaceEntityHandler- Specified by:
createQueryin interfaceSharedSessionContract- Parameters:
typedQueryReference- the type query reference- Returns:
- The
Queryinstance for execution - See Also:
-
createQuery
Description copied from interface:SharedSessionContract- Specified by:
createQueryin interfaceEntityHandler- Specified by:
createQueryin interfaceSharedSessionContract- See Also:
-
createStatement
Description copied from interface:SharedSessionContract- Specified by:
createStatementin interfaceEntityHandler- Specified by:
createStatementin interfaceSharedSessionContract- See Also:
-
createSelectionQuery
Description copied from interface:SharedSessionContractCreate aSelectionQueryreference for the givenCriteriaQuery.- Specified by:
createSelectionQueryin interfaceSharedSessionContract- See Also:
-
createSelectionQuery
Description copied from interface:SharedSessionContractCreate aSelectionQueryreference for the givenCriteriaQuery.- Specified by:
createSelectionQueryin interfaceSharedSessionContract- See Also:
-
createMutationQuery
Description copied from interface:SharedSessionContractCreate aMutationQueryfrom the given update criteria tree- Specified by:
createMutationQueryin interfaceSharedSessionContract
-
createMutationQuery
Description copied from interface:SharedSessionContractCreate aMutationQueryfrom the given insert criteria tree- Specified by:
createMutationQueryin interfaceSharedSessionContract
-
createNativeQuery
Description copied from interface:SharedSessionContractCreate aNativeQueryinstance for the given native SQL query.- Specified by:
createNativeQueryin interfaceEntityHandler- Specified by:
createNativeQueryin interfaceSharedSessionContract- Parameters:
sqlString- The native (SQL) query string- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
-
createNativeQuery
@Nonnull public <R> NativeQuery<R> createNativeQuery(@Nonnull String sqlString, @Nonnull Class<R> resultClass) Description copied from interface:SharedSessionContractCreate 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 interfaceEntityHandler- Specified by:
createNativeQueryin interfaceSharedSessionContract- 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:SharedSessionContractCreate 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 interfaceSharedSessionContract- 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
public <R> NativeQuery<R> createNativeQuery(String sqlString, String resultSetMappingName, Class<R> resultClass) Description copied from interface:SharedSessionContractCreate 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 interfaceSharedSessionContract- Parameters:
sqlString- The native (SQL) query stringresultSetMappingName- The explicit result mapping name- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
-
createNativeMutationQuery
Description copied from interface:SharedSessionContractCreate aNativeQueryinstance for the given native SQL statement.- Specified by:
createNativeMutationQueryin interfaceSharedSessionContract- Parameters:
sqlString- a native SQL statement string- Returns:
- The NativeQuery instance for manipulation and execution
-
createNamedQuery
@Nonnull public <R> SelectionQuery<R> createNamedQuery(@Nonnull String name, @Nonnull Class<R> resultClass) Description copied from interface:SharedSessionContractCreate a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQueryin interfaceEntityHandler- Specified by:
createNamedQueryin interfaceSharedSessionContract- 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:
-
createNamedStatement
- Specified by:
createNamedStatementin interfaceEntityHandler- Specified by:
createNamedStatementin interfaceSharedSessionContract
-
createNamedQuery
@Nonnull public <R> NativeQuery<R> createNamedQuery(@Nonnull String name, @Nonnull String resultSetMappingName) - Specified by:
createNamedQueryin interfaceSharedSessionContract
-
createNamedQuery
@Nonnull public <R> NativeQuery<R> createNamedQuery(@Nonnull String name, @Nonnull String resultSetMappingName, @Nonnull Class<R> resultClass) - Specified by:
createNamedQueryin interfaceSharedSessionContract
-
createNativeStatement
- Specified by:
createNativeStatementin interfaceEntityHandler- Specified by:
createNativeStatementin interfaceSharedSessionContract
-
createNativeQuery
@Nonnull public NativeQuery<?> createNativeQuery(@Nonnull String sql, @Nonnull String resultSetMapping) - Specified by:
createNativeQueryin interfaceEntityHandler- Specified by:
createNativeQueryin interfaceSharedSessionContract
-
createNativeQuery
@Nonnull public <T> TypedQuery<T> createNativeQuery(@Nonnull String sql, @Nonnull jakarta.persistence.sql.ResultSetMapping<T> resultSetMapping) - Specified by:
createNativeQueryin interfaceEntityHandler- Specified by:
createNativeQueryin interfaceSharedSessionContract
-
createNamedSelectionQuery
@Nonnull public <R> SelectionQuery<R> createNamedSelectionQuery(@Nonnull String name, @Nonnull Class<R> resultType) Description copied from interface:SharedSessionContractCreate aSelectionQueryinstance for the namedNamedQuerywith the given result type.- Specified by:
createNamedSelectionQueryin interfaceSharedSessionContract
-
createNamedMutationQuery
Description copied from interface:SharedSessionContractCreate 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 interfaceSharedSessionContract
-
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
@Nonnull public ProcedureCall createStoredProcedureCall(@Nonnull String procedureName, @Nonnull Class<?>... resultClasses) 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
@Nonnull public ProcedureCall createStoredProcedureCall(@Nonnull String procedureName, @Nonnull String... resultSetMappings) 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 interfaceEntityHandler- 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 interfaceEntityHandler- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
@Nonnull public ProcedureCall createStoredProcedureQuery(@Nonnull String procedureName, @Nonnull Class<?>... resultClasses) 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 interfaceEntityHandler- 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
@Nonnull public ProcedureCall createStoredProcedureQuery(@Nonnull String procedureName, @Nonnull String... resultSetMappings) Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQueryin interfaceEntityHandler- 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 interfaceEntityHandler- 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.
-
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).
-
runWithConnection
- Specified by:
runWithConnectionin interfaceEntityHandler
-
callWithConnection
- Specified by:
callWithConnectionin interfaceEntityHandler
-
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 interfaceEntityHandler- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
rootType- the root entity class of the graph- See Also:
-
createEntityGraph
@Deprecated(since="8.0", forRemoval=true) @Nullable public RootGraph<?> createEntityGraph(@Nonnull String graphName) Deprecated, for removal: This API element is subject to removal in a future version.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
-
createEntityGraph
@Deprecated(since="8.0", forRemoval=true) @Nullable public <T> RootGraph<T> createEntityGraph(@Nonnull Class<T> rootType, @Nonnull String graphName) Deprecated, for removal: This API element is subject to removal in a future version.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
-
getEntityGraph
Description copied from interface:SharedSessionContractObtain a mutable copy of a predefined named entity graph.- Specified by:
getEntityGraphin interfaceEntityHandler- Specified by:
getEntityGraphin interfaceSharedSessionContract- Parameters:
graphName- the name of the predefined named entity graph- See Also:
-
getEntityGraph
@Nonnull public <T> RootGraph<T> getEntityGraph(@Nonnull Class<T> rootType, @Nonnull String graphName) Description copied from interface:SharedSessionContractObtain a mutable copy of a predefined named entity graph whose root type is exactly the given entity type.- Specified by:
getEntityGraphin interfaceEntityHandler- Specified by:
getEntityGraphin interfaceSharedSessionContract- Parameters:
rootType- the root entity class of the graphgraphName- 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 interfaceEntityHandler- 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
-
getEntityManagerFactory
- Specified by:
getEntityManagerFactoryin interfaceEntityHandler
-
getMetamodel
- Specified by:
getMetamodelin interfaceEntityHandler
-
unwrap
- Specified by:
unwrapin interfaceEntityHandler
-
getProperties
- Specified by:
getPropertiesin interfaceEntityHandler
-
setProperty
- Specified by:
setPropertyin interfaceEntityHandler
-
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
-
createQuery
Description copied from interface:SharedSessionContractCreate an instance ofQueryfor the given HQL query or statement, without indicating the expected result type, if any, nor whether the query is a typed query which returns a result list, or an update, delete, or insert statement.- Specified by:
createQueryin interfaceEntityHandler- Specified by:
createQueryin interfaceSharedSessionContract
-
createNamedQuery
Description copied from interface:SharedSessionContractCreate an instance ofQueryfor the given named query or statement, without indicating the expected result type, if any, nor whether the query is a typed query which returns a result list, or an update, delete, or insert statement.- Specified by:
createNamedQueryin interfaceEntityHandler- Specified by:
createNamedQueryin interfaceSharedSessionContract
-