-
public interface PanacheCompanionBase<Entity extends PanacheEntityBase, Id extends Object>Defines methods to be used via the companion objects of entities.
-
-
Method Summary
Modifier and Type Method Description EntityManagergetEntityManager()Returns the EntityManager for the <Entity> for extra operations (eg. 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. 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. BooleandeleteById(Id id)Delete an entity of this type by ID. 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. 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. Unitflush()Flushes all pending changes to the database. -
-
Method Detail
-
getEntityManager
@GenerateBridge() EntityManager getEntityManager()
Returns the EntityManager for the <Entity> for extra operations (eg. CriteriaQueries)
-
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.
-
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
-
deleteById
@GenerateBridge() Boolean deleteById(Id id)
Delete an entity of this type by ID.
- Parameters:
id- the ID of the entity to delete.
-
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
-
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
-
update
@GenerateBridge() Integer update(String query, Parameters params)
Update all entities of this type matching the given query, with named parameters.
- Parameters:
query- a query stringparams- Parameters of named parameters
-
-
-
-