Entity - The type of entity to operate onId - The ID type of the entitypublic interface PanacheRepositoryBase<Entity,Id>
Represents a Repository for a specific type of entity Entity, with an ID type
of Id. Implementing this repository will gain you the exact same useful methods
that are on PanacheEntityBase. Unless you have a custom ID strategy, you should not
implement this interface directly but implement PanacheRepository instead.
| Modifier and Type | Method and Description |
|---|---|
default long |
count()
Counts the number of this type of entity in the database.
|
default long |
count(String query,
Map<String,Object> params)
Counts the number of this type of entity matching the given query, with named parameters.
|
default long |
count(String query,
Object... params)
Counts the number of this type of entity matching the given query, with optional indexed parameters.
|
default long |
count(String query,
Parameters params)
Counts the number of this type of entity matching the given query, with named parameters.
|
default void |
delete(Entity entity)
Delete the given entity from the database, if it is already persisted.
|
default long |
delete(String query,
Map<String,Object> params)
Delete all entities of this type matching the given query, with named parameters.
|
default long |
delete(String query,
Object... params)
Delete all entities of this type matching the given query, with optional indexed parameters.
|
default long |
delete(String query,
Parameters params)
Delete all entities of this type matching the given query, with named parameters.
|
default long |
deleteAll()
Delete all entities of this type from the database.
|
default boolean |
deleteById(Id id)
Delete an entity of this type by ID.
|
default PanacheQuery<Entity> |
find(String query,
Map<String,Object> params)
Find entities using a query, with named parameters.
|
default PanacheQuery<Entity> |
find(String query,
Object... params)
Find entities using a query, with optional indexed parameters.
|
default PanacheQuery<Entity> |
find(String query,
Parameters params)
Find entities using a query, with named parameters.
|
default PanacheQuery<Entity> |
find(String query,
Sort sort,
Map<String,Object> params)
Find entities using a query and the given sort options, with named parameters.
|
default PanacheQuery<Entity> |
find(String query,
Sort sort,
Object... params)
Find entities using a query and the given sort options, with optional indexed parameters.
|
default PanacheQuery<Entity> |
find(String query,
Sort sort,
Parameters params)
Find entities using a query and the given sort options, with named parameters.
|
default PanacheQuery<Entity> |
findAll()
Find all entities of this type.
|
default PanacheQuery<Entity> |
findAll(Sort sort)
Find all entities of this type, in the given order.
|
default Entity |
findById(Id id)
Find an entity of this type by ID.
|
default Entity |
findById(Id id,
javax.persistence.LockModeType lockModeType)
Find an entity of this type by ID and lock it.
|
default Optional<Entity> |
findByIdOptional(Id id)
Find an entity of this type by ID.
|
default Optional<Entity> |
findByIdOptional(Id id,
javax.persistence.LockModeType lockModeType)
Find an entity of this type by ID.
|
default void |
flush()
FFlushes all pending changes to the database using the default EntityManager.
|
default javax.persistence.EntityManager |
getEntityManager()
Returns the default
EntityManager for extra operations (eg. |
default javax.persistence.EntityManager |
getEntityManager(Class<?> clazz)
Returns the
EntityManager for the given entity class |
default boolean |
isPersistent(Entity entity)
Returns true if the given entity is persistent in the database.
|
default List<Entity> |
list(String query,
Map<String,Object> params)
Find entities matching a query, with named parameters.
|
default List<Entity> |
list(String query,
Object... params)
Find entities matching a query, with optional indexed parameters.
|
default List<Entity> |
list(String query,
Parameters params)
Find entities matching a query, with named parameters.
|
default List<Entity> |
list(String query,
Sort sort,
Map<String,Object> params)
Find entities matching a query and the given sort options, with named parameters.
|
default List<Entity> |
list(String query,
Sort sort,
Object... params)
Find entities matching a query and the given sort options, with optional indexed parameters.
|
default List<Entity> |
list(String query,
Sort sort,
Parameters params)
Find entities matching a query and the given sort options, with named parameters.
|
default List<Entity> |
listAll()
Find all entities of this type.
|
default List<Entity> |
listAll(Sort sort)
Find all entities of this type, in the given order.
|
default void |
persist(Entity entity)
Persist the given entity in the database, if not already persisted.
|
default void |
persist(Entity firstEntity,
Entity... entities)
Persist all given entities.
|
default void |
persist(Iterable<Entity> entities)
Persist all given entities.
|
default void |
persist(Stream<Entity> entities)
Persist all given entities.
|
default void |
persistAndFlush(Entity entity)
Persist the given entity in the database, if not already persisted.
|
default Stream<Entity> |
stream(String query,
Map<String,Object> params)
Find entities matching a query, with named parameters.
|
default Stream<Entity> |
stream(String query,
Object... params)
Find entities matching a query, with optional indexed parameters.
|
default Stream<Entity> |
stream(String query,
Parameters params)
Find entities matching a query, with named parameters.
|
default Stream<Entity> |
stream(String query,
Sort sort,
Map<String,Object> params)
Find entities matching a query and the given sort options, with named parameters.
|
default Stream<Entity> |
stream(String query,
Sort sort,
Object... params)
Find entities matching a query and the given sort options, with optional indexed parameters.
|
default Stream<Entity> |
stream(String query,
Sort sort,
Parameters params)
Find entities matching a query and the given sort options, with named parameters.
|
default Stream<Entity> |
streamAll()
Find all entities of this type, in the given order.
|
default Stream<Entity> |
streamAll(Sort sort)
Find all entities of this type.
|
default int |
update(String query,
Map<String,Object> params)
Update all entities of this type matching the given query, with named parameters.
|
default int |
update(String query,
Object... params)
Update all entities of this type matching the given query, with optional indexed parameters.
|
default int |
update(String query,
Parameters params)
Update all entities of this type matching the given query, with named parameters.
|
default javax.persistence.EntityManager getEntityManager()
EntityManager for extra operations (eg. CriteriaQueries)EntityManagerdefault javax.persistence.EntityManager getEntityManager(Class<?> clazz)
EntityManager for the given entity classEntityManagerdefault void persist(Entity entity)
entity - the entity to persist.isPersistent(Object),
persist(Iterable),
persist(Stream),
persist(Object, Object...)default void persistAndFlush(Entity entity)
entity - the entity to persist.isPersistent(Object),
persist(Iterable),
persist(Stream),
persist(Object, Object...)default void delete(Entity entity)
entity - the entity to delete.isPersistent(Object),
delete(String, Object...),
delete(String, Map),
delete(String, Parameters),
deleteAll()default boolean isPersistent(Entity entity)
entity - the entity to checkdefault void flush()
@GenerateBridge(targetReturnTypeErased=true) default Entity findById(Id id)
id - the ID of the entity to find.null if not found.@GenerateBridge(targetReturnTypeErased=true) default Entity findById(Id id, javax.persistence.LockModeType lockModeType)
id - the ID of the entity to find.lockModeType - the locking strategy to be used when retrieving the entity.null if not found.@GenerateBridge default Optional<Entity> findByIdOptional(Id id)
id - the ID of the entity to find.Optional.empty().@GenerateBridge default Optional<Entity> findByIdOptional(Id id, javax.persistence.LockModeType lockModeType)
id - the ID of the entity to find.Optional.empty().@GenerateBridge default PanacheQuery<Entity> find(String query, Object... params)
query - a query stringparams - optional sequence of indexed parametersPanacheQuery instance for the given queryfind(String, Sort, Object...),
find(String, Map),
find(String, Parameters),
list(String, Object...),
stream(String, Object...)@GenerateBridge default PanacheQuery<Entity> find(String query, Sort sort, Object... params)
query - a query stringsort - the sort strategy to useparams - optional sequence of indexed parametersPanacheQuery instance for the given queryfind(String, Object...),
find(String, Sort, Map),
find(String, Sort, Parameters),
list(String, Sort, Object...),
stream(String, Sort, Object...)@GenerateBridge default PanacheQuery<Entity> find(String query, Map<String,Object> params)
query - a query stringparams - Map of named parametersPanacheQuery instance for the given queryfind(String, Sort, Map),
find(String, Object...),
find(String, Parameters),
list(String, Map),
stream(String, Map)@GenerateBridge default PanacheQuery<Entity> find(String query, Sort sort, Map<String,Object> params)
query - a query stringsort - the sort strategy to useparams - Map of indexed parametersPanacheQuery instance for the given queryfind(String, Map),
find(String, Sort, Object...),
find(String, Sort, Parameters),
list(String, Sort, Map),
stream(String, Sort, Map)@GenerateBridge default PanacheQuery<Entity> find(String query, Parameters params)
query - a query stringparams - Parameters of named parametersPanacheQuery instance for the given queryfind(String, Sort, Parameters),
find(String, Map),
find(String, Parameters),
list(String, Parameters),
stream(String, Parameters)@GenerateBridge default PanacheQuery<Entity> find(String query, Sort sort, Parameters params)
query - a query stringsort - the sort strategy to useparams - Parameters of indexed parametersPanacheQuery instance for the given queryfind(String, Parameters),
find(String, Sort, Map),
find(String, Sort, Parameters),
list(String, Sort, Parameters),
stream(String, Sort, Parameters)@GenerateBridge default PanacheQuery<Entity> findAll()
PanacheQuery instance to find all entities of this type.findAll(Sort),
listAll(),
streamAll()@GenerateBridge default PanacheQuery<Entity> findAll(Sort sort)
sort - the sort order to usePanacheQuery instance to find all entities of this type.findAll(),
listAll(Sort),
streamAll(Sort)@GenerateBridge default List<Entity> list(String query, Object... params)
find(query, params).list().query - a query stringparams - optional sequence of indexed parametersList containing all results, without paginglist(String, Sort, Object...),
list(String, Map),
list(String, Parameters),
find(String, Object...),
stream(String, Object...)@GenerateBridge default List<Entity> list(String query, Sort sort, Object... params)
find(query, sort, params).list().query - a query stringsort - the sort strategy to useparams - optional sequence of indexed parametersList containing all results, without paginglist(String, Object...),
list(String, Sort, Map),
list(String, Sort, Parameters),
find(String, Sort, Object...),
stream(String, Sort, Object...)@GenerateBridge default List<Entity> list(String query, Map<String,Object> params)
find(query, params).list().query - a query stringparams - Map of named parametersList containing all results, without paginglist(String, Sort, Map),
list(String, Object...),
list(String, Parameters),
find(String, Map),
stream(String, Map)@GenerateBridge default List<Entity> list(String query, Sort sort, Map<String,Object> params)
find(query, sort, params).list().query - a query stringsort - the sort strategy to useparams - Map of indexed parametersList containing all results, without paginglist(String, Map),
list(String, Sort, Object...),
list(String, Sort, Parameters),
find(String, Sort, Map),
stream(String, Sort, Map)@GenerateBridge default List<Entity> list(String query, Parameters params)
find(query, params).list().query - a query stringparams - Parameters of named parametersList containing all results, without paginglist(String, Sort, Parameters),
list(String, Object...),
list(String, Map),
find(String, Parameters),
stream(String, Parameters)@GenerateBridge default List<Entity> list(String query, Sort sort, Parameters params)
find(query, sort, params).list().query - a query stringsort - the sort strategy to useparams - Parameters of indexed parametersList containing all results, without paginglist(String, Parameters),
list(String, Sort, Object...),
list(String, Sort, Map),
find(String, Sort, Parameters),
stream(String, Sort, Parameters)@GenerateBridge default List<Entity> listAll()
findAll().list().List containing all results, without paginglistAll(Sort),
findAll(),
streamAll()@GenerateBridge default List<Entity> listAll(Sort sort)
findAll(sort).list().sort - the sort order to useList containing all results, without paginglistAll(),
findAll(Sort),
streamAll(Sort)@GenerateBridge default Stream<Entity> stream(String query, Object... params)
find(query, params).stream().
It requires a transaction to work.
Without a transaction, the underlying cursor can be closed before the end of the stream.query - a query stringparams - optional sequence of indexed parametersStream containing all results, without pagingstream(String, Sort, Object...),
stream(String, Map),
stream(String, Parameters),
find(String, Object...),
list(String, Object...)@GenerateBridge default Stream<Entity> stream(String query, Sort sort, Object... params)
find(query, sort, params).stream().
It requires a transaction to work.
Without a transaction, the underlying cursor can be closed before the end of the stream.query - a query stringsort - the sort strategy to useparams - optional sequence of indexed parametersStream containing all results, without pagingstream(String, Object...),
stream(String, Sort, Map),
stream(String, Sort, Parameters),
find(String, Sort, Object...),
list(String, Sort, Object...)@GenerateBridge default Stream<Entity> stream(String query, Map<String,Object> params)
find(query, params).stream().
It requires a transaction to work.
Without a transaction, the underlying cursor can be closed before the end of the stream.query - a query stringparams - Map of named parametersStream containing all results, without pagingstream(String, Sort, Map),
stream(String, Object...),
stream(String, Parameters),
find(String, Map),
list(String, Map)@GenerateBridge default Stream<Entity> stream(String query, Sort sort, Map<String,Object> params)
find(query, sort, params).stream().
It requires a transaction to work.
Without a transaction, the underlying cursor can be closed before the end of the stream.query - a query stringsort - the sort strategy to useparams - Map of indexed parametersStream containing all results, without pagingstream(String, Map),
stream(String, Sort, Object...),
stream(String, Sort, Parameters),
find(String, Sort, Map),
list(String, Sort, Map)@GenerateBridge default Stream<Entity> stream(String query, Parameters params)
find(query, params).stream().
It requires a transaction to work.
Without a transaction, the underlying cursor can be closed before the end of the stream.query - a query stringparams - Parameters of named parametersStream containing all results, without pagingstream(String, Sort, Parameters),
stream(String, Object...),
stream(String, Map),
find(String, Parameters),
list(String, Parameters)@GenerateBridge default Stream<Entity> stream(String query, Sort sort, Parameters params)
find(query, sort, params).stream().
It requires a transaction to work.
Without a transaction, the underlying cursor can be closed before the end of the stream.query - a query stringsort - the sort strategy to useparams - Parameters of indexed parametersStream containing all results, without pagingstream(String, Parameters),
stream(String, Sort, Object...),
stream(String, Sort, Map),
find(String, Sort, Parameters),
list(String, Sort, Parameters)@GenerateBridge default Stream<Entity> streamAll(Sort sort)
findAll().stream().
It requires a transaction to work.
Without a transaction, the underlying cursor can be closed before the end of the stream.Stream containing all results, without pagingstreamAll(Sort),
findAll(),
listAll()@GenerateBridge default Stream<Entity> streamAll()
findAll().stream().
It requires a transaction to work.
Without a transaction, the underlying cursor can be closed before the end of the stream.Stream containing all results, without pagingstreamAll(),
findAll(Sort),
listAll(Sort)@GenerateBridge default long count()
count(String, Object...),
count(String, Map),
count(String, Parameters)@GenerateBridge default long count(String query, Object... params)
query - a query stringparams - optional sequence of indexed parameterscount(),
count(String, Map),
count(String, Parameters)@GenerateBridge default long count(String query, Map<String,Object> params)
query - a query stringparams - Map of named parameterscount(),
count(String, Object...),
count(String, Parameters)@GenerateBridge default long count(String query, Parameters params)
query - a query stringparams - Parameters of named parameterscount(),
count(String, Object...),
count(String, Map)@GenerateBridge default long deleteAll()
delete(String, Object...),
delete(String, Map),
delete(String, Parameters)@GenerateBridge default boolean deleteById(Id id)
id - the ID of the entity to delete.@GenerateBridge default long delete(String query, Object... params)
query - a query stringparams - optional sequence of indexed parametersdeleteAll(),
delete(String, Map),
delete(String, Parameters)@GenerateBridge default long delete(String query, Map<String,Object> params)
query - a query stringparams - Map of named parametersdeleteAll(),
delete(String, Object...),
delete(String, Parameters)@GenerateBridge default long delete(String query, Parameters params)
query - a query stringparams - Parameters of named parametersdeleteAll(),
delete(String, Object...),
delete(String, Map)default void persist(Iterable<Entity> entities)
entities - the entities to persistpersist(Object),
persist(Stream),
persist(Object,Object...)default void persist(Stream<Entity> entities)
entities - the entities to persistpersist(Object),
persist(Iterable),
persist(Object,Object...)default void persist(Entity firstEntity, Entity... entities)
entities - the entities to persistpersist(Object),
persist(Stream),
persist(Iterable)@GenerateBridge default int update(String query, Object... params)
query - a query stringparams - optional sequence of indexed parametersupdate(String, Map),
update(String, Parameters)@GenerateBridge default int update(String query, Map<String,Object> params)
query - a query stringparams - Map of named parametersupdate(String, Object...),
update(String, Parameters)@GenerateBridge default int update(String query, Parameters params)
query - a query stringparams - Parameters of named parametersupdate(String, Object...),
update(String, Map)Copyright © 2021 JBoss by Red Hat. All rights reserved.