Class Queries.QueriesBase

java.lang.Object
org.opencastproject.db.Queries.QueriesBase
Direct Known Subclasses:
Queries.TypedQueriesBase
Enclosing class:
Queries

public abstract static class Queries.QueriesBase extends Object
  • Constructor Details

    • QueriesBase

      public QueriesBase()
  • Method Details

    • find

      public Function<javax.persistence.EntityManager,Object> find(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:
      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

      public Function<javax.persistence.EntityManager,List> findAll(String q, Object... params)
      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

      public Function<javax.persistence.EntityManager,Integer> update(String q, Object... params)
      Execute a named update query.
      Parameters:
      q - Name of the query.
      params - Parameters passed to the query.
      Returns:
      The number of updated entities.
    • delete

      public Function<javax.persistence.EntityManager,Integer> delete(String q, Object... params)
      Execute a named delete query.
      Parameters:
      q - Name of the query.
      params - Parameters passed to the query.
      Returns:
      The number of deleted entities.
    • persistOrUpdate

      public <E> Function<javax.persistence.EntityManager,E> persistOrUpdate(E entity)
      Create or update passed entity.
      Type Parameters:
      E - Entity type.
      Parameters:
      entity - Entity to create or update.
      Returns:
      Created or updated entity.
    • remove

      public <E> Consumer<javax.persistence.EntityManager> remove(E entity)
      Delete passed entity.
      Type Parameters:
      E - Entity type.
      Parameters:
      entity - Entity to delete.
      Returns:
      Deleted entity.
    • persist

      public <E> Function<javax.persistence.EntityManager,E> persist(E entity)
      Create passed entity.
      Type Parameters:
      E - Entity type.
      Parameters:
      entity - Entity to create.
      Returns:
      Created entity.
    • persistOpt

      public <E> Function<javax.persistence.EntityManager,Optional<E>> persistOpt(E entity)
      Create passed entity.
      Type Parameters:
      E - Entity type.
      Parameters:
      entity - Entity to create.
      Returns:
      Optional with the created entity.
    • createQuery

      protected abstract javax.persistence.Query createQuery(javax.persistence.EntityManager em, String q, Object... params)
    • configureQuery

      protected javax.persistence.Query configureQuery(javax.persistence.Query q, Object... params)