Package io.micronaut.data.operations
Interface RepositoryOperations
-
- All Superinterfaces:
io.micronaut.context.ApplicationContextProvider
,HintsCapableRepository
- All Known Subinterfaces:
AsyncCapableRepository
,BlockingExecutorReactorRepositoryOperations
,BlockingReactorRepositoryOperations
,BlockingReactorRepositoryOperations
,JdbcRepositoryOperations
,JpaRepositoryOperations
,MongoRepositoryOperations
,PrimaryRepositoryOperations
,R2dbcRepositoryOperations
,ReactiveCapableRepository
,ReactorReactiveCapableRepository
,ReactorReactiveCapableRepository
- All Known Implementing Classes:
DefaultJdbcRepositoryOperations
,DefaultMongoRepositoryOperations
,HibernateJpaOperations
public interface RepositoryOperations extends HintsCapableRepository, io.micronaut.context.ApplicationContextProvider
Common interface for repository implementations to implement.- Since:
- 1.0
- Author:
- graemerocher
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <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.default java.util.Optional<java.lang.Number>
executeDelete(PreparedQuery<?,java.lang.Number> preparedQuery)
Executes a delete for the given query and parameter values.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,R>
RfindOne(PreparedQuery<T,R> preparedQuery)
Find one by Query.<T> T
findOne(java.lang.Class<T> type, java.io.Serializable id)
Find one by ID.<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> query)
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.default io.micronaut.core.convert.ConversionService<?>
getConversionService()
Get conversion service.default <T> RuntimePersistentEntity<T>
getEntity(java.lang.Class<T> type)
Retrieves the entity for the given type.<T> T
persist(InsertOperation<T> operation)
Persist the operation returning a possibly new entity.default <T> java.lang.Iterable<T>
persistAll(InsertBatchOperation<T> operation)
Persist all the given entities.<T> T
update(UpdateOperation<T> operation)
Updates the entity for the given operation.default <T> java.lang.Iterable<T>
updateAll(UpdateBatchOperation<T> operation)
Updates the entities for the given operation.-
Methods inherited from interface io.micronaut.context.ApplicationContextProvider
getApplicationContext
-
Methods inherited from interface io.micronaut.data.operations.HintsCapableRepository
getQueryHints
-
-
-
-
Method Detail
-
getEntity
@NonNull default <T> RuntimePersistentEntity<T> getEntity(@NonNull java.lang.Class<T> type)
Retrieves the entity for the given type.- Type Parameters:
T
- The generic Type- Parameters:
type
- The type- Returns:
- The entity
- Throws:
io.micronaut.core.beans.exceptions.IntrospectionException
- if no entity exists of the given type
-
findOne
@Nullable <T> T findOne(@NonNull java.lang.Class<T> type, @NonNull java.io.Serializable id)
Find one by ID.- Type Parameters:
T
- The generic type- Parameters:
type
- The typeid
- The id- Returns:
- A result or null
-
findOne
@Nullable <T,R> R findOne(@NonNull PreparedQuery<T,R> preparedQuery)
Find one by Query.- Type Parameters:
T
- The generic resultTypeR
- The result type- Parameters:
preparedQuery
- The prepared query- Returns:
- A result or null
-
exists
<T> boolean exists(@NonNull PreparedQuery<T,java.lang.Boolean> preparedQuery)
Execute a query that checks for existence.- Type Parameters:
T
- The generic resultType- Parameters:
preparedQuery
- The prepared query- Returns:
- A result or null
-
findAll
@NonNull <T> java.lang.Iterable<T> findAll(@NonNull PagedQuery<T> query)
Finds all results for the given query.- Type Parameters:
T
- The generic type- Parameters:
query
- The root entity- Returns:
- An iterable result
-
count
<T> long count(PagedQuery<T> pagedQuery)
Counts all results for the given query.- Type Parameters:
T
- The generic type- Parameters:
pagedQuery
- The paged query- Returns:
- An iterable result
-
findAll
@NonNull <T,R> java.lang.Iterable<R> findAll(@NonNull PreparedQuery<T,R> preparedQuery)
Finds all results for the given query.- Type Parameters:
T
- The entity typeR
- The result type- Parameters:
preparedQuery
- The prepared query- Returns:
- An iterable result
-
findStream
@NonNull <T,R> java.util.stream.Stream<R> findStream(@NonNull PreparedQuery<T,R> preparedQuery)
Finds all results for the given query.- Type Parameters:
T
- The entity typeR
- The result type- Parameters:
preparedQuery
- The prepared query- Returns:
- An iterable result
-
findStream
@NonNull <T> java.util.stream.Stream<T> findStream(@NonNull PagedQuery<T> query)
Finds a stream for the given arguments.- Type Parameters:
T
- The generic type- Parameters:
query
- The query- Returns:
- The stream
-
findPage
<R> Page<R> findPage(@NonNull PagedQuery<R> query)
Find a page for the given entity and pageable.- Type Parameters:
R
- The entity generic type- Parameters:
query
- The query- Returns:
- The page type
-
persist
@NonNull <T> T persist(@NonNull InsertOperation<T> operation)
Persist the operation returning a possibly new entity.- Type Parameters:
T
- The generic type- Parameters:
operation
- The operation- Returns:
- The operation
-
update
@NonNull <T> T update(@NonNull UpdateOperation<T> operation)
Updates the entity for the given operation.- Type Parameters:
T
- The generic type- Parameters:
operation
- The operation- Returns:
- The operation
-
updateAll
@NonNull default <T> java.lang.Iterable<T> updateAll(@NonNull UpdateBatchOperation<T> operation)
Updates the entities for the given operation.- Type Parameters:
T
- The generic type- Parameters:
operation
- The operation- Returns:
- The updated entities
-
persistAll
@NonNull default <T> java.lang.Iterable<T> persistAll(@NonNull InsertBatchOperation<T> operation)
Persist all the given entities.- Type Parameters:
T
- The generic type- Parameters:
operation
- The operation- Returns:
- The entities, possibly mutated
-
executeUpdate
@NonNull java.util.Optional<java.lang.Number> executeUpdate(@NonNull PreparedQuery<?,java.lang.Number> preparedQuery)
Executes an update for the given query and parameter values. If it is possible to return the number of objects updated, then do so.- Parameters:
preparedQuery
- The prepared query- Returns:
- An optional number with the count of the number of records updated
-
executeDelete
@NonNull default java.util.Optional<java.lang.Number> executeDelete(@NonNull PreparedQuery<?,java.lang.Number> preparedQuery)
Executes a delete for the given query and parameter values. If it is possible to return the number of objects deleted, then do so.- Parameters:
preparedQuery
- The prepared query- Returns:
- An optional number with the count of the number of records updated
-
delete
<T> int delete(@NonNull DeleteOperation<T> operation)
Deletes the entity.- Type Parameters:
T
- The generic type- Parameters:
operation
- The operation- Returns:
- The number of entities deleted
-
deleteAll
<T> java.util.Optional<java.lang.Number> deleteAll(@NonNull DeleteBatchOperation<T> operation)
Deletes all the entities of the given type.- Type Parameters:
T
- The generic type- Parameters:
operation
- The operation- Returns:
- The number of entities deleted
-
getConversionService
default io.micronaut.core.convert.ConversionService<?> getConversionService()
Get conversion service.- Returns:
- the instance of
ConversionService
-
-