Package org.opencastproject.db
Class Queries.QueriesBase
java.lang.Object
org.opencastproject.db.Queries.QueriesBase
- Direct Known Subclasses:
Queries.TypedQueriesBase
- Enclosing class:
Queries
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected javax.persistence.QueryconfigureQuery(javax.persistence.Query q, Object... params) protected abstract javax.persistence.QuerycreateQuery(javax.persistence.EntityManager em, String q, Object... params) Execute a named delete query.Execute a named query and return a single result.Execute a named query and return all results.Execute a named query and return a single result.<E> Function<javax.persistence.EntityManager, E> persist(E entity) Create passed entity.persistOpt(E entity) Create passed entity.<E> Function<javax.persistence.EntityManager, E> persistOrUpdate(E entity) Create or update passed entity.<E> Consumer<javax.persistence.EntityManager> remove(E entity) Delete passed entity.Execute a named update query.
-
Constructor Details
-
QueriesBase
public QueriesBase()
-
-
Method Details
-
find
Execute a named query and return a single result.- Parameters:
q- Name of the query.params- Parameters passed to the query.- Returns:
- The entity. An exception is thrown if not found.
-
findOpt
public Function<javax.persistence.EntityManager,Optional<Object>> findOpt(String q, Object... params) Execute a named query and return a single result.- Parameters:
q- Name of the query.params- Parameters passed to the query.- Returns:
- An Optional with the entity or an empty Optional if not found.
-
findAll
Execute a named query and return all results.- Parameters:
q- Name of the query.params- Parameters passed to the query.- Returns:
- A list of entities.
-
update
Execute a named update query.- Parameters:
q- Name of the query.params- Parameters passed to the query.- Returns:
- The number of updated entities.
-
delete
Execute a named delete query.- Parameters:
q- Name of the query.params- Parameters passed to the query.- Returns:
- The number of deleted entities.
-
persistOrUpdate
Create or update passed entity.- Type Parameters:
E- Entity type.- Parameters:
entity- Entity to create or update.- Returns:
- Created or updated entity.
-
remove
Delete passed entity.- Type Parameters:
E- Entity type.- Parameters:
entity- Entity to delete.- Returns:
- Deleted entity.
-
persist
Create passed entity.- Type Parameters:
E- Entity type.- Parameters:
entity- Entity to create.- Returns:
- Created entity.
-
persistOpt
Create passed entity.- Type Parameters:
E- Entity type.- Parameters:
entity- Entity to create.- Returns:
- Optional with the created entity.
-
createQuery
-
configureQuery
-