@EachBean(value=org.hibernate.SessionFactory.class) public class HibernateJpaOperations extends java.lang.Object implements JpaRepositoryOperations, AsyncCapableRepository, ReactiveCapableRepository
JpaRepositoryOperations
interface for Hibernate.Modifier | Constructor and Description |
---|---|
protected |
HibernateJpaOperations(org.hibernate.SessionFactory sessionFactory,
TransactionOperations<java.sql.Connection> transactionOperations,
java.util.concurrent.ExecutorService executorService,
RuntimeEntityRegistry runtimeEntityRegistry)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
ExecutorAsyncOperations |
async() |
<T> long |
count(PagedQuery<T> pagedQuery)
Counts all results for the given query.
|
<T> int |
delete(DeleteOperation<T> operation)
Deletes the entity.
|
<T> java.util.Optional<java.lang.Number> |
deleteAll(DeleteBatchOperation<T> operation)
Deletes all the entities of the given type.
|
java.util.Optional<java.lang.Number> |
executeUpdate(PreparedQuery<?,java.lang.Number> preparedQuery)
Executes an update for the given query and parameter values.
|
<T> boolean |
exists(PreparedQuery<T,java.lang.Boolean> preparedQuery)
Execute a query that checks for existence.
|
<T> java.lang.Iterable<T> |
findAll(PagedQuery<T> query)
Finds all results for the given query.
|
<T,R> java.lang.Iterable<R> |
findAll(PreparedQuery<T,R> preparedQuery)
Finds all results for the given query.
|
<T> T |
findOne(java.lang.Class<T> type,
java.io.Serializable id)
Find one by ID.
|
<T,R> R |
findOne(PreparedQuery<T,R> preparedQuery)
Find one by Query.
|
<R> Page<R> |
findPage(PagedQuery<R> query)
Find a page for the given entity and pageable.
|
<T> java.util.stream.Stream<T> |
findStream(PagedQuery<T> pagedQuery)
Finds a stream for the given arguments.
|
<T,R> java.util.stream.Stream<R> |
findStream(PreparedQuery<T,R> preparedQuery)
Finds all results for the given query.
|
void |
flush()
Flush the current session.
|
io.micronaut.context.ApplicationContext |
getApplicationContext() |
javax.persistence.EntityManager |
getCurrentEntityManager() |
javax.persistence.EntityManagerFactory |
getEntityManagerFactory() |
java.util.Map<java.lang.String,java.lang.Object> |
getQueryHints(StoredQuery<?,?> storedQuery)
Obtain any custom query hints for this method and repository implementation.
|
<T> T |
load(java.lang.Class<T> type,
java.io.Serializable id)
Create an uninitialized proxy.
|
<T> T |
persist(InsertOperation<T> operation)
Persist the operation returning a possibly new entity.
|
<T> java.lang.Iterable<T> |
persistAll(InsertBatchOperation<T> operation)
Persist all the given entities.
|
ReactiveRepositoryOperations |
reactive() |
<T> T |
update(UpdateOperation<T> operation)
Updates the entity for the given operation.
|
<T> java.lang.Iterable<T> |
updateAll(UpdateBatchOperation<T> operation)
Updates the entities for the given operation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
executeDelete, getEntity
protected HibernateJpaOperations(@NonNull org.hibernate.SessionFactory sessionFactory, @NonNull @Parameter TransactionOperations<java.sql.Connection> transactionOperations, @Named(value="io") @Nullable java.util.concurrent.ExecutorService executorService, RuntimeEntityRegistry runtimeEntityRegistry)
sessionFactory
- The session factorytransactionOperations
- The transaction operationsexecutorService
- The executor service for I/O tasks to useruntimeEntityRegistry
- The runtime entity registrypublic io.micronaut.context.ApplicationContext getApplicationContext()
getApplicationContext
in interface io.micronaut.context.ApplicationContextProvider
@NonNull public java.util.Map<java.lang.String,java.lang.Object> getQueryHints(@NonNull StoredQuery<?,?> storedQuery)
RepositoryOperations
getQueryHints
in interface RepositoryOperations
storedQuery
- The stored query@Nullable public <T> T findOne(@NonNull java.lang.Class<T> type, @NonNull java.io.Serializable id)
RepositoryOperations
findOne
in interface RepositoryOperations
T
- The generic typetype
- The typeid
- The id@NonNull public <T> T load(@NonNull java.lang.Class<T> type, @NonNull java.io.Serializable id)
JpaRepositoryOperations
load
in interface JpaRepositoryOperations
T
- the entity typetype
- the entity typeid
- the entity id@Nullable public <T,R> R findOne(@NonNull PreparedQuery<T,R> preparedQuery)
RepositoryOperations
findOne
in interface RepositoryOperations
T
- The generic resultTypeR
- The result typepreparedQuery
- The prepared querypublic <T> boolean exists(@NonNull PreparedQuery<T,java.lang.Boolean> preparedQuery)
RepositoryOperations
exists
in interface RepositoryOperations
T
- The generic resultTypepreparedQuery
- The prepared query@NonNull public <T> java.lang.Iterable<T> findAll(@NonNull PagedQuery<T> query)
RepositoryOperations
findAll
in interface RepositoryOperations
T
- The generic typequery
- The root entitypublic <T> long count(PagedQuery<T> pagedQuery)
RepositoryOperations
count
in interface RepositoryOperations
T
- The generic typepagedQuery
- The paged query@NonNull public <T,R> java.lang.Iterable<R> findAll(@NonNull PreparedQuery<T,R> preparedQuery)
RepositoryOperations
findAll
in interface RepositoryOperations
T
- The entity typeR
- The result typepreparedQuery
- The prepared querypublic <T> T persist(@NonNull InsertOperation<T> operation)
RepositoryOperations
persist
in interface RepositoryOperations
T
- The generic typeoperation
- The operation@NonNull public <T> T update(@NonNull UpdateOperation<T> operation)
RepositoryOperations
update
in interface RepositoryOperations
T
- The generic typeoperation
- The operation@NonNull public <T> java.lang.Iterable<T> updateAll(@NonNull UpdateBatchOperation<T> operation)
RepositoryOperations
updateAll
in interface RepositoryOperations
T
- The generic typeoperation
- The operation@NonNull public <T> java.lang.Iterable<T> persistAll(@NonNull InsertBatchOperation<T> operation)
RepositoryOperations
persistAll
in interface RepositoryOperations
T
- The generic typeoperation
- The operation@NonNull public java.util.Optional<java.lang.Number> executeUpdate(@NonNull PreparedQuery<?,java.lang.Number> preparedQuery)
RepositoryOperations
executeUpdate
in interface RepositoryOperations
preparedQuery
- The prepared querypublic <T> int delete(@NonNull DeleteOperation<T> operation)
RepositoryOperations
delete
in interface RepositoryOperations
T
- The generic typeoperation
- The operationpublic <T> java.util.Optional<java.lang.Number> deleteAll(@NonNull DeleteBatchOperation<T> operation)
RepositoryOperations
deleteAll
in interface RepositoryOperations
T
- The generic typeoperation
- The operation@NonNull public <T,R> java.util.stream.Stream<R> findStream(@NonNull PreparedQuery<T,R> preparedQuery)
RepositoryOperations
findStream
in interface RepositoryOperations
T
- The entity typeR
- The result typepreparedQuery
- The prepared query@NonNull public <T> java.util.stream.Stream<T> findStream(@NonNull PagedQuery<T> pagedQuery)
RepositoryOperations
findStream
in interface RepositoryOperations
T
- The generic typepagedQuery
- The querypublic <R> Page<R> findPage(@NonNull PagedQuery<R> query)
RepositoryOperations
findPage
in interface RepositoryOperations
R
- The entity generic typequery
- The query@NonNull public ExecutorAsyncOperations async()
async
in interface AsyncCapableRepository
@NonNull public ReactiveRepositoryOperations reactive()
reactive
in interface ReactiveCapableRepository
@NonNull public javax.persistence.EntityManager getCurrentEntityManager()
getCurrentEntityManager
in interface JpaRepositoryOperations
@NonNull public javax.persistence.EntityManagerFactory getEntityManagerFactory()
getEntityManagerFactory
in interface JpaRepositoryOperations
public void flush()
JpaRepositoryOperations
flush
in interface JpaRepositoryOperations