-
public interface PanacheRepositoryBase<Entity extends Object, Id extends Object>Represents a Repository for a specific type of entity
Entity, with an ID type ofId. Implementing this interface will gain you the exact same useful methods that are on PanacheEntity and PanacheCompanion.
-
-
Method Summary
Modifier and Type Method Description EntityManagergetEntityManager()Returns the EntityManager for the <Entity> for extra operations (eg. EntityManagergetEntityManager(KClass<Object> clazz)Returns the EntityManager tied to the given class for extra operations (eg. Unitpersist(Entity entity)Persist the given entity in the database, if not already persisted. Unitpersist(Iterable<Entity> entities)Persist all given entities. Unitpersist(Stream<Entity> entities)Persist all given entities. Unitpersist(Entity firstEntity, Entity entities)Persist all given entities. UnitpersistAndFlush(Entity entity)Persist the given entity in the database, if not already persisted. Unitdelete(Entity entity)Delete the given entity from the database, if it is already persisted. Longdelete(String query, Object params)Delete all entities of this type matching the given query, with optional indexed parameters. Longdelete(String query, Map<String, Object> params)Delete all entities of this type matching the given query, with named parameters. Longdelete(String query, Parameters params)Delete all entities of this type matching the given query, with named parameters. BooleanisPersistent(Entity entity)Returns true if the given entity is persistent in the database. Unitflush()Flushes all pending changes to the database using the default EntityManager. EntityfindById(Id id)Find an entity of this type by ID. EntityfindById(Id id, LockModeType lockModeType)Find an entity of this type by ID and lock it. PanacheQuery<Entity>find(String query, Object params)Find entities using a query, with optional indexed parameters. PanacheQuery<Entity>find(String query, Sort sort, Object params)Find entities using a query and the given sort options, with optional indexed parameters. PanacheQuery<Entity>find(String query, Map<String, Object> params)Find entities using a query, with named parameters. PanacheQuery<Entity>find(String query, Sort sort, Map<String, Object> params)Find entities using a query and the given sort options, with named parameters. PanacheQuery<Entity>find(String query, Parameters params)Find entities using a query, with named parameters. PanacheQuery<Entity>find(String query, Sort sort, Parameters params)Find entities using a query and the given sort options, with named parameters. PanacheQuery<Entity>findAll()Find all entities of this type. PanacheQuery<Entity>findAll(Sort sort)Find all entities of this type, in the given order. List<Entity>list(String query, Object params)Find entities matching a query, with optional indexed parameters. List<Entity>list(String query, Sort sort, Object params)Find entities matching a query and the given sort options, with optional indexed parameters. List<Entity>list(String query, Map<String, Object> params)Find entities matching a query, with named parameters. List<Entity>list(String query, Sort sort, Map<String, Object> params)Find entities matching a query and the given sort options, with named parameters. List<Entity>list(String query, Parameters params)Find entities matching a query, with named parameters. List<Entity>list(String query, Sort sort, Parameters params)Find entities matching a query and the given sort options, with named parameters. List<Entity>listAll()Find all entities of this type. List<Entity>listAll(Sort sort)Find all entities of this type, in the given order. Stream<Entity>stream(String query, Object params)Find entities matching a query, with optional indexed parameters. Stream<Entity>stream(String query, Sort sort, Object params)Find entities matching a query and the given sort options, with optional indexed parameters. Stream<Entity>stream(String query, Map<String, Object> params)Find entities matching a query, with named parameters. Stream<Entity>stream(String query, Sort sort, Map<String, Object> params)Find entities matching a query and the given sort options, with named parameters. Stream<Entity>stream(String query, Parameters params)Find entities matching a query, with named parameters. Stream<Entity>stream(String query, Sort sort, Parameters params)Find entities matching a query and the given sort options, with named parameters. Stream<Entity>streamAll()Find all entities of this type. Stream<Entity>streamAll(Sort sort)Find all entities of this type, in the given order. Longcount()Counts the number of this type of entity in the database. Longcount(String query, Object params)Counts the number of this type of entity matching the given query, with optional indexed parameters. Longcount(String query, Map<String, Object> params)Counts the number of this type of entity matching the given query, with named parameters. Longcount(String query, Parameters params)Counts the number of this type of entity matching the given query, with named parameters. LongdeleteAll()Delete all entities of this type from the database. BooleandeleteById(Id id)Delete an entity of this type by ID. Integerupdate(String query, Object params)Update all entities of this type matching the given query, with optional indexed parameters. Integerupdate(String query, Map<String, Object> params)Update all entities of this type matching the given query, with named parameters. Integerupdate(String query, Parameters params)Update all entities of this type matching the given query, with named parameters. -
-
Method Detail
-
getEntityManager
@GenerateBridge() EntityManager getEntityManager()
Returns the EntityManager for the <Entity> for extra operations (eg. CriteriaQueries)
-
getEntityManager
@GenerateBridge()@Deprecated(message = use Panache.getEntityManager(Class) instead to access an entity manager for any entity class) EntityManager getEntityManager(KClass<Object> clazz)
Returns the EntityManager tied to the given class for extra operations (eg. CriteriaQueries)
-
persist
Unit persist(Entity entity)
Persist the given entity in the database, if not already persisted.
- Parameters:
entity- the entity to persist.
-
persist
Unit persist(Iterable<Entity> entities)
Persist all given entities.
- Parameters:
entities- the entities to persist
-
persist
Unit persist(Stream<Entity> entities)
Persist all given entities.
- Parameters:
entities- the entities to persist
-
persist
Unit persist(Entity firstEntity, Entity entities)
Persist all given entities.
- Parameters:
entities- the entities to persist
-
persistAndFlush
Unit persistAndFlush(Entity entity)
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.
-
delete
Unit delete(Entity entity)
Delete the given entity from the database, if it is already persisted.
- Parameters:
entity- the entity to delete.
-
delete
@GenerateBridge() Long delete(String query, Object params)
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- a query stringparams- optional sequence of indexed parameters
-
delete
@GenerateBridge() Long delete(String query, Map<String, Object> 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- a query stringparams- Map of named parameters
-
delete
@GenerateBridge() Long delete(String query, 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- a query stringparams- Parameters of named parameters
-
isPersistent
Boolean isPersistent(Entity entity)
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
-
findById
@GenerateBridge(targetReturnTypeErased = true) Entity findById(Id id)
Find an entity of this type by ID.
- Parameters:
id- the ID of the entity to find.
-
findById
@GenerateBridge(targetReturnTypeErased = true) Entity findById(Id id, 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.
-
find
@GenerateBridge() PanacheQuery<Entity> find(String query, Object params)
Find entities using a query, with optional indexed parameters.
- Parameters:
query- a query stringparams- optional sequence of indexed parameters
-
find
@GenerateBridge() PanacheQuery<Entity> find(String query, Sort sort, Object params)
Find entities using a query and the given sort options, with optional indexed parameters.
- Parameters:
query- a query stringsort- the sort strategy to useparams- optional sequence of indexed parameters
-
find
@GenerateBridge() PanacheQuery<Entity> find(String query, Map<String, Object> params)
Find entities using a query, with named parameters.
- Parameters:
query- a query stringparams- Map of named parameters
-
find
@GenerateBridge() PanacheQuery<Entity> find(String query, Sort sort, Map<String, Object> params)
Find entities using a query and the given sort options, with named parameters.
- Parameters:
query- a query stringsort- the sort strategy to useparams- Map of indexed parameters
-
find
@GenerateBridge() PanacheQuery<Entity> find(String query, Parameters params)
Find entities using a query, with named parameters.
- Parameters:
query- a query stringparams- Parameters of named parameters
-
find
@GenerateBridge() PanacheQuery<Entity> find(String query, Sort sort, Parameters params)
Find entities using a query and the given sort options, with named parameters.
- Parameters:
query- a query stringsort- the sort strategy to useparams- Parameters of indexed parameters
-
findAll
@GenerateBridge() PanacheQuery<Entity> findAll()
Find all entities of this type.
-
findAll
@GenerateBridge() PanacheQuery<Entity> findAll(Sort sort)
Find all entities of this type, in the given order.
- Parameters:
sort- the sort order to use
-
list
@GenerateBridge() List<Entity> list(String query, Object params)
Find entities matching a query, with optional indexed parameters. This method is a shortcut for
find(query, params).list().- Parameters:
query- a query stringparams- optional sequence of indexed parameters
-
list
@GenerateBridge() List<Entity> list(String query, Sort sort, Object params)
Find entities matching a query and the given sort options, with optional indexed parameters. This method is a shortcut for
find(query, sort, params).list().- Parameters:
query- a query stringsort- the sort strategy to useparams- optional sequence of indexed parameters
-
list
@GenerateBridge() List<Entity> list(String query, Map<String, Object> params)
Find entities matching a query, with named parameters. This method is a shortcut for
find(query, params).list().- Parameters:
query- a query stringparams- Map of named parameters
-
list
@GenerateBridge() List<Entity> list(String query, Sort sort, Map<String, Object> params)
Find entities matching a query and the given sort options, with named parameters. This method is a shortcut for
find(query, sort, params).list().- Parameters:
query- a query stringsort- the sort strategy to useparams- Map of indexed parameters
-
list
@GenerateBridge() List<Entity> list(String query, Parameters params)
Find entities matching a query, with named parameters. This method is a shortcut for
find(query, params).list().- Parameters:
query- a query stringparams- Parameters of named parameters
-
list
@GenerateBridge() List<Entity> list(String query, Sort sort, Parameters params)
Find entities matching a query and the given sort options, with named parameters. This method is a shortcut for
find(query, sort, params).list().- Parameters:
query- a query stringsort- the sort strategy to useparams- Parameters of indexed parameters
-
listAll
@GenerateBridge() List<Entity> listAll()
Find all entities of this type. This method is a shortcut for
findAll().list().
-
listAll
@GenerateBridge() List<Entity> listAll(Sort sort)
Find all entities of this type, in the given order. This method is a shortcut for
findAll(sort).list().- Parameters:
sort- the sort order to use
-
stream
@GenerateBridge() Stream<Entity> stream(String query, Object params)
Find entities matching a query, with optional indexed parameters. This method is a shortcut for
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.- Parameters:
query- a query stringparams- optional sequence of indexed parameters
-
stream
@GenerateBridge() Stream<Entity> stream(String query, Sort sort, Object params)
Find entities matching a query and the given sort options, with optional indexed parameters. This method is a shortcut for
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.- Parameters:
query- a query stringsort- the sort strategy to useparams- optional sequence of indexed parameters
-
stream
@GenerateBridge() Stream<Entity> stream(String query, Map<String, Object> params)
Find entities matching a query, with named parameters. This method is a shortcut for
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.- Parameters:
query- a query stringparams- Map of named parameters
-
stream
@GenerateBridge() Stream<Entity> stream(String query, Sort sort, Map<String, Object> params)
Find entities matching a query and the given sort options, with named parameters. This method is a shortcut for
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.- Parameters:
query- a query stringsort- the sort strategy to useparams- Map of indexed parameters
-
stream
@GenerateBridge() Stream<Entity> stream(String query, Parameters params)
Find entities matching a query, with named parameters. This method is a shortcut for
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.- Parameters:
query- a query stringparams- Parameters of named parameters
-
stream
@GenerateBridge() Stream<Entity> stream(String query, Sort sort, Parameters params)
Find entities matching a query and the given sort options, with named parameters. This method is a shortcut for
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.- Parameters:
query- a query stringsort- the sort strategy to useparams- Parameters of indexed parameters
-
streamAll
@GenerateBridge() Stream<Entity> streamAll()
Find all entities of this type. This method is a shortcut for
findAll().stream(). It requires a transaction to work. Without a transaction, the underlying cursor can be closed before the end of the stream.
-
streamAll
@GenerateBridge() Stream<Entity> streamAll(Sort sort)
Find all entities of this type, in the given order. This method is a shortcut for
findAll(sort).stream(). It requires a transaction to work. Without a transaction, the underlying cursor can be closed before the end of the stream.- Parameters:
sort- the sort order to use
-
count
@GenerateBridge() Long count(String query, Object params)
Counts the number of this type of entity matching the given query, with optional indexed parameters.
- Parameters:
query- a query stringparams- optional sequence of indexed parameters
-
count
@GenerateBridge() Long count(String query, Map<String, Object> params)
Counts the number of this type of entity matching the given query, with named parameters.
- Parameters:
query- a query stringparams- Map of named parameters
-
count
@GenerateBridge() Long count(String query, Parameters params)
Counts the number of this type of entity matching the given query, with named parameters.
- Parameters:
query- a query stringparams- Parameters of named parameters
-
deleteAll
@GenerateBridge() 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.
-
deleteById
@GenerateBridge() Boolean deleteById(Id id)
Delete an entity of this type by ID.
- Parameters:
id- the ID of the entity to delete.
-
update
@GenerateBridge() Integer update(String query, Object params)
Update all entities of this type matching the given query, with optional indexed parameters.
- Parameters:
query- a query stringparams- optional sequence of indexed parameters
-
update
@GenerateBridge() Integer update(String query, Map<String, Object> params)
Update all entities of this type matching the given query, with named parameters.
- Parameters:
query- a query stringparams- Map of named parameters
-
-
-
-