Package 

Interface PanacheRepositoryBase

  • All Implemented Interfaces:

    
    public interface PanacheRepositoryBase<Entity extends Object, Id extends Object>
    
                        

    Represents a Repository for a specific type of entity Entity, with an ID type of Id. Implementing this interface will gain you the exact same useful methods that are on PanacheEntity and PanacheCompanion.

    • Constructor Detail

    • 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 string
        params - 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 string
        params - 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 string
        params - 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
      • flush

         Unit flush()

        Flushes all pending changes to the database using the EntityManager for the <Entity> entity class.

      • 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 string
        params - 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 string
        sort - the sort strategy to use
        params - optional sequence of indexed 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 string
        sort - the sort strategy to use
        params - 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 string
        params - 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 string
        sort - the sort strategy to use
        params - Parameters of indexed parameters
      • 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 string
        params - 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 string
        sort - the sort strategy to use
        params - 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 string
        params - 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 string
        sort - the sort strategy to use
        params - 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 string
        params - 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 string
        sort - the sort strategy to use
        params - 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 string
        params - 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 string
        sort - the sort strategy to use
        params - 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 string
        params - 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 string
        sort - the sort strategy to use
        params - 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 string
        params - 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 string
        sort - the sort strategy to use
        params - 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()

        Counts the number of this type of entity in the database.

      • 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 string
        params - 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 string
        params - 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 string
        params - 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 string
        params - 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 string
        params - 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 string
        params - Parameters of named parameters