Interface PanacheRepositoryBase<Entity,Id>
- Type Parameters:
Entity- The type of entity to operate onId- The ID type of the entity
- All Known Subinterfaces:
PanacheRepository<Entity>
public 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.
-
Method Summary
Modifier and TypeMethodDescriptiondefault longcount()Counts the number of this type of entity in the database.default longCounts the number of this type of entity matching the given query, with named parameters.default longCounts the number of this type of entity matching the given query, with optional indexed parameters.default longCounts the number of this type of entity matching the given query, with named parameters.default voidDelete the given entity from the database, if it is already persisted.default longDelete all entities of this type from the database.default booleandeleteById(Id id) Delete an entity of this type by ID.default longdeleteByQuery(String query, io.quarkus.panache.common.Parameters params) Delete all entities of this type matching the given query, with named parameters.default longdeleteByQuery(String query, Object... params) Delete all entities of this type matching the given query, with optional indexed parameters.default longdeleteByQuery(String query, Map<String, Object> params) Delete all entities of this type matching the given query, with named parameters.default PanacheQuery<Entity>Find entities using a query, with named parameters.default PanacheQuery<Entity>find(String query, io.quarkus.panache.common.Sort sort, io.quarkus.panache.common.Parameters params) Find entities using a query and the given sort options, with named parameters.default PanacheQuery<Entity>Find entities using a query and the given sort options, with optional indexed parameters.default PanacheQuery<Entity>Find entities using a query and the given sort options, with named parameters.default PanacheQuery<Entity>Find entities using a query, with optional indexed parameters.default PanacheQuery<Entity>Find entities using a query, with named parameters.default PanacheQuery<Entity>findAll()Find all entities of this type.default PanacheQuery<Entity>findAll(io.quarkus.panache.common.Sort sort) Find all entities of this type, in the given order.default EntityFind an entity of this type by ID.default EntityFind an entity of this type by ID and lock it.findByIdOptional(Id id) Find an entity of this type by ID.findByIdOptional(Id id, jakarta.persistence.LockModeType lockModeType) Find an entity of this type by ID.default voidflush()Flushes all pending changes to the database using the EntityManager for theentity class. default jakarta.persistence.EntityManagerReturns theEntityManagerfor theentity class for extra operations (eg. default booleanisPersistent(Entity entity) Returns true if the given entity is persistent in the database.Find entities matching a query, with named parameters.list(String query, io.quarkus.panache.common.Sort sort, io.quarkus.panache.common.Parameters params) Find entities matching a query and the given sort options, with named parameters.Find entities matching a query and the given sort options, with optional indexed parameters.Find entities matching a query and the given sort options, with named parameters.Find entities matching a query, with optional indexed parameters.Find entities matching a query, with named parameters.listAll()Find all entities of this type.listAll(io.quarkus.panache.common.Sort sort) Find all entities of this type, in the given order.default voidPersist the given entity in the database, if not already persisted.default voidPersist all given entities.default voidPersist all given entities.default voidPersist all given entities.default voidpersistAndFlush(Entity entity) Persist the given entity in the database, if not already persisted.Find entities matching a query, with named parameters.stream(String query, io.quarkus.panache.common.Sort sort, io.quarkus.panache.common.Parameters params) Find entities matching a query and the given sort options, with named parameters.Find entities matching a query and the given sort options, with optional indexed parameters.Find entities matching a query and the given sort options, with named parameters.Find entities matching a query, with optional indexed parameters.Find entities matching a query, with named parameters.Find all entities of this type, in the given order.streamAll(io.quarkus.panache.common.Sort sort) Find all entities of this type.default intUpdate all entities of this type matching the given query, with named parameters.default intUpdate all entities of this type matching the given query, with optional indexed parameters.default intUpdate all entities of this type matching the given query, with named parameters.
-
Method Details
-
getEntityManager
@GenerateBridge default jakarta.persistence.EntityManager getEntityManager()Returns theEntityManagerfor theentity class for extra operations (eg. CriteriaQueries) - Returns:
- the
EntityManagerfor theentity class
-
persist
Persist the given entity in the database, if not already persisted.- Parameters:
entity- the entity to persist.- See Also:
-
persistAndFlush
Persist the given entity in the database, if not already persisted. Then flushes all pending changes to the database.- Parameters:
entity- the entity to persist.- See Also:
-
delete
Delete the given entity from the database, if it is already persisted.- Parameters:
entity- the entity to delete.- See Also:
-
isPersistent
Returns true if the given entity is persistent in the database. If yes, all modifications to its persistent fields will be automatically committed to the database at transaction commit time.- Parameters:
entity- the entity to check- Returns:
- true if the entity is persistent in the database.
-
flush
default void flush()Flushes all pending changes to the database using the EntityManager for theentity class. -
findById
Find an entity of this type by ID.- Parameters:
id- the ID of the entity to find.- Returns:
- the entity found, or
nullif not found.
-
findById
@GenerateBridge(targetReturnTypeErased=true) default Entity findById(Id id, jakarta.persistence.LockModeType lockModeType) Find an entity of this type by ID and lock it.- Parameters:
id- the ID of the entity to find.lockModeType- the locking strategy to be used when retrieving the entity.- Returns:
- the entity found, or
nullif not found.
-
findByIdOptional
Find an entity of this type by ID.- Parameters:
id- the ID of the entity to find.- Returns:
- if found, an optional containing the entity, else
Optional.empty().
-
findByIdOptional
@GenerateBridge default Optional<Entity> findByIdOptional(Id id, jakarta.persistence.LockModeType lockModeType) Find an entity of this type by ID.- Parameters:
id- the ID of the entity to find.- Returns:
- if found, an optional containing the entity, else
Optional.empty().
-
find
Find entities using a query, with optional indexed parameters.- Parameters:
query- aquery stringparams- optional sequence of indexed parameters- Returns:
- a new
PanacheQueryinstance for the given query - See Also:
-
find
@GenerateBridge default PanacheQuery<Entity> find(String query, io.quarkus.panache.common.Sort sort, Object... params) Find entities using a query and the given sort options, with optional indexed parameters.- Parameters:
query- aquery stringsort- the sort strategy to useparams- optional sequence of indexed parameters- Returns:
- a new
PanacheQueryinstance for the given query - See Also:
-
find
Find entities using a query, with named parameters.- Parameters:
query- aquery stringparams-Mapof named parameters- Returns:
- a new
PanacheQueryinstance for the given query - See Also:
-
find
@GenerateBridge default PanacheQuery<Entity> find(String query, io.quarkus.panache.common.Sort sort, Map<String, Object> params) Find entities using a query and the given sort options, with named parameters.- Parameters:
query- aquery stringsort- the sort strategy to useparams-Mapof indexed parameters- Returns:
- a new
PanacheQueryinstance for the given query - See Also:
-
find
@GenerateBridge default PanacheQuery<Entity> find(String query, io.quarkus.panache.common.Parameters params) Find entities using a query, with named parameters.- Parameters:
query- aquery stringparams-Parametersof named parameters- Returns:
- a new
PanacheQueryinstance for the given query - See Also:
-
find
@GenerateBridge default PanacheQuery<Entity> find(String query, io.quarkus.panache.common.Sort sort, io.quarkus.panache.common.Parameters params) Find entities using a query and the given sort options, with named parameters.- Parameters:
query- aquery stringsort- the sort strategy to useparams-Parametersof indexed parameters- Returns:
- a new
PanacheQueryinstance for the given query - See Also:
-
findAll
Find all entities of this type.- Returns:
- a new
PanacheQueryinstance to find all entities of this type. - See Also:
-
findAll
Find all entities of this type, in the given order.- Parameters:
sort- the sort order to use- Returns:
- a new
PanacheQueryinstance to find all entities of this type. - See Also:
-
list
Find entities matching a query, with optional indexed parameters. This method is a shortcut forfind(query, params).list().- Parameters:
query- aquery stringparams- optional sequence of indexed parameters- Returns:
- a
Listcontaining all results, without paging - See Also:
-
list
@GenerateBridge default List<Entity> list(String query, io.quarkus.panache.common.Sort sort, Object... params) Find entities matching a query and the given sort options, with optional indexed parameters. This method is a shortcut forfind(query, sort, params).list().- Parameters:
query- aquery stringsort- the sort strategy to useparams- optional sequence of indexed parameters- Returns:
- a
Listcontaining all results, without paging - See Also:
-
list
Find entities matching a query, with named parameters. This method is a shortcut forfind(query, params).list(). -
list
@GenerateBridge default List<Entity> list(String query, io.quarkus.panache.common.Sort sort, Map<String, Object> params) Find entities matching a query and the given sort options, with named parameters. This method is a shortcut forfind(query, sort, params).list(). -
list
@GenerateBridge default List<Entity> list(String query, io.quarkus.panache.common.Parameters params) Find entities matching a query, with named parameters. This method is a shortcut forfind(query, params).list().- Parameters:
query- aquery stringparams-Parametersof named parameters- Returns:
- a
Listcontaining all results, without paging - See Also:
-
list
@GenerateBridge default List<Entity> list(String query, io.quarkus.panache.common.Sort sort, io.quarkus.panache.common.Parameters params) Find entities matching a query and the given sort options, with named parameters. This method is a shortcut forfind(query, sort, params).list().- Parameters:
query- aquery stringsort- the sort strategy to useparams-Parametersof indexed parameters- Returns:
- a
Listcontaining all results, without paging - See Also:
-
listAll
Find all entities of this type. This method is a shortcut forfindAll().list().- Returns:
- a
Listcontaining all results, without paging - See Also:
-
listAll
Find all entities of this type, in the given order. This method is a shortcut forfindAll(sort).list().- Parameters:
sort- the sort order to use- Returns:
- a
Listcontaining all results, without paging - See Also:
-
stream
Find entities matching a query, with optional indexed parameters. This method is a shortcut forfind(query, params).stream(). It requires a transaction to work. Without a transaction, the underlying cursor can be closed before the end of the stream.- Parameters:
query- aquery stringparams- optional sequence of indexed parameters- Returns:
- a
Streamcontaining all results, without paging - See Also:
-
stream
@GenerateBridge default Stream<Entity> stream(String query, io.quarkus.panache.common.Sort sort, Object... params) Find entities matching a query and the given sort options, with optional indexed parameters. This method is a shortcut forfind(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.- Parameters:
query- aquery stringsort- the sort strategy to useparams- optional sequence of indexed parameters- Returns:
- a
Streamcontaining all results, without paging - See Also:
-
stream
Find entities matching a query, with named parameters. This method is a shortcut forfind(query, params).stream(). It requires a transaction to work. Without a transaction, the underlying cursor can be closed before the end of the stream. -
stream
@GenerateBridge default Stream<Entity> stream(String query, io.quarkus.panache.common.Sort sort, Map<String, Object> params) Find entities matching a query and the given sort options, with named parameters. This method is a shortcut forfind(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. -
stream
@GenerateBridge default Stream<Entity> stream(String query, io.quarkus.panache.common.Parameters params) Find entities matching a query, with named parameters. This method is a shortcut forfind(query, params).stream(). It requires a transaction to work. Without a transaction, the underlying cursor can be closed before the end of the stream.- Parameters:
query- aquery stringparams-Parametersof named parameters- Returns:
- a
Streamcontaining all results, without paging - See Also:
-
stream
@GenerateBridge default Stream<Entity> stream(String query, io.quarkus.panache.common.Sort sort, io.quarkus.panache.common.Parameters params) Find entities matching a query and the given sort options, with named parameters. This method is a shortcut forfind(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.- Parameters:
query- aquery stringsort- the sort strategy to useparams-Parametersof indexed parameters- Returns:
- a
Streamcontaining all results, without paging - See Also:
-
streamAll
Find all entities of this type. This method is a shortcut forfindAll().stream(). It requires a transaction to work. Without a transaction, the underlying cursor can be closed before the end of the stream.- Returns:
- a
Streamcontaining all results, without paging - See Also:
-
streamAll
Find all entities of this type, in the given order. This method is a shortcut forfindAll().stream(). It requires a transaction to work. Without a transaction, the underlying cursor can be closed before the end of the stream.- Returns:
- a
Streamcontaining all results, without paging - See Also:
-
count
@GenerateBridge default long count()Counts the number of this type of entity in the database.- Returns:
- the number of this type of entity in the database.
- See Also:
-
count
Counts the number of this type of entity matching the given query, with optional indexed parameters.- Parameters:
query- aquery stringparams- optional sequence of indexed parameters- Returns:
- the number of entities counted.
- See Also:
-
count
Counts the number of this type of entity matching the given query, with named parameters.- Parameters:
query- aquery stringparams-Mapof named parameters- Returns:
- the number of entities counted.
- See Also:
-
count
Counts the number of this type of entity matching the given query, with named parameters.- Parameters:
query- aquery stringparams-Parametersof named parameters- Returns:
- the number of entities counted.
- See Also:
-
deleteAll
@GenerateBridge default long deleteAll()Delete all entities of this type from the database. WARNING: the default implementation of this method uses a bulk delete query and ignores cascading rules from the JPA model.- Returns:
- the number of entities deleted.
- See Also:
-
deleteById
Delete an entity of this type by ID.- Parameters:
id- the ID of the entity to delete.- Returns:
- false if the entity was not deleted (not found).
-
deleteByQuery
Delete all entities of this type matching the given query, with optional indexed parameters. WARNING: the default implementation of this method uses a bulk delete query and ignores cascading rules from the JPA model.- Parameters:
query- aquery stringparams- optional sequence of indexed parameters- Returns:
- the number of entities deleted.
- See Also:
-
deleteByQuery
Delete all entities of this type matching the given query, with named parameters. WARNING: the default implementation of this method uses a bulk delete query and ignores cascading rules from the JPA model.- Parameters:
query- aquery stringparams-Mapof named parameters- Returns:
- the number of entities deleted.
- See Also:
-
deleteByQuery
@GenerateBridge default long deleteByQuery(String query, io.quarkus.panache.common.Parameters params) Delete all entities of this type matching the given query, with named parameters. WARNING: the default implementation of this method uses a bulk delete query and ignores cascading rules from the JPA model.- Parameters:
query- aquery stringparams-Parametersof named parameters- Returns:
- the number of entities deleted.
- See Also:
-
persist
Persist all given entities.- Parameters:
entities- the entities to persist- See Also:
-
persist
Persist all given entities.- Parameters:
entities- the entities to persist- See Also:
-
persist
Persist all given entities.- Parameters:
entities- the entities to persist- See Also:
-
update
Update all entities of this type matching the given query, with optional indexed parameters.- Parameters:
query- aquery stringparams- optional sequence of indexed parameters- Returns:
- the number of entities updated.
- See Also:
-
update
Update all entities of this type matching the given query, with named parameters.- Parameters:
query- aquery stringparams-Mapof named parameters- Returns:
- the number of entities updated.
- See Also:
-
update
Update all entities of this type matching the given query, with named parameters.- Parameters:
query- aquery stringparams-Parametersof named parameters- Returns:
- the number of entities updated.
- See Also:
-