Interface BaseRepository<E,​T>

  • Type Parameters:
    E - the type of the entity to handle
    T - the type of the entity's identifier
    All Superinterfaces:
    org.springframework.data.repository.CrudRepository<E,​T>, org.springframework.data.jpa.repository.JpaRepository<E,​T>, org.springframework.data.repository.PagingAndSortingRepository<E,​T>, org.springframework.data.repository.query.QueryByExampleExecutor<E>, org.springframework.data.repository.Repository<E,​T>

    @NoRepositoryBean
    public interface BaseRepository<E,​T>
    extends org.springframework.data.jpa.repository.JpaRepository<E,​T>
    Central repository marker interface. Captures the domain type to manage as well as the domain type's id type. General purpose is to hold type information as well as being able to discover interfaces that extend this one during classpath scanning for easy Spring bean creation.
    Since:
    1.0.0
    Author:
    Dharmesh Khandelwal, Shashank Agrawal
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      E create​(E entity)
      Make an instance managed and persistent and synchronize the persistence context to the underlying database.
      List<E> createNamedQuerySelect​(String name, Class<E> entityClass, Map<String,​Object> params)
      Create a SELECT TypedQuery for executing a Java Persistence query language named query.
      int createNamedQueryUpdateOrDelete​(String name, Class<E> entityClass, Map<String,​Object> params)
      Create a update or delete TypedQuery for executing a Java Persistence query language named query.
      List<E> createQuerySelect​(String qlString, Map<String,​Object> params)
      Create a SELECT Query for executing a Java Persistence query language statement and execute the query and return the query results as an untyped List.
      List<E> createQuerySelect​(String qlString, Map<String,​Object> params, int limit)
      Create a SELECT Query for executing a Java Persistence query language statement and execute the query and return the query results as an untyped List.
      int createQueryUpdateOrDelete​(String qlString, Map<String,​Object> params)
      Create an update or delete Query for executing a Java Persistence query language statement and execute the statement.
      T delete​(Class<E> entityClass, T id)
      Remove the entity instance of the specified primary key
      List<E> findAll​(Class<E> entityClass)
      Find all entities for the specified class
      E findById​(Class<E> entityClass, T id)
      Find by primary key.
      E update​(E entity)
      Merge the state of the given entity into the current persistence context.
      • Methods inherited from interface org.springframework.data.repository.CrudRepository

        count, delete, deleteAll, deleteAll, deleteById, existsById, findById, save
      • Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

        deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getOne, saveAll, saveAndFlush
      • Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

        findAll
      • Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

        count, exists, findAll, findOne
    • Method Detail

      • create

        E create​(E entity)
        Make an instance managed and persistent and synchronize the persistence context to the underlying database.
        Parameters:
        entity - entity instance
        Returns:
        the managed instance
      • update

        E update​(E entity)
        Merge the state of the given entity into the current persistence context.
        Parameters:
        entity - entity instance
        Returns:
        the managed instance that the state was merged to
      • findById

        E findById​(Class<E> entityClass,
                   T id)
        Find by primary key. Search for an entity of the specified class and primary key. If the entity instance is contained in the persistence context, it is returned from there.
        Parameters:
        entityClass - The entityClass
        id - primary key
        Returns:
        the found entity instance or null if the entity does not exist
      • findAll

        List<E> findAll​(Class<E> entityClass)
        Find all entities for the specified class
        Parameters:
        entityClass - The entityClass
        Returns:
        List of all entities found
      • delete

        T delete​(Class<E> entityClass,
                 T id)
        Remove the entity instance of the specified primary key
        Parameters:
        entityClass - The entityClass
        id - primary key
        Returns:
        primary key for which entity was removed
      • createQuerySelect

        List<E> createQuerySelect​(String qlString,
                                  Map<String,​Object> params)
        Create a SELECT Query for executing a Java Persistence query language statement and execute the query and return the query results as an untyped List.
        Parameters:
        qlString - a Java Persistence query string
        params - Map of parameters to bind an argument to a named parameter.
        Returns:
        a list of the results
      • createQuerySelect

        List<E> createQuerySelect​(String qlString,
                                  Map<String,​Object> params,
                                  int limit)
        Create a SELECT Query for executing a Java Persistence query language statement and execute the query and return the query results as an untyped List.
        Parameters:
        qlString - a Java Persistence query string
        params - Map of parameters to bind an argument to a named parameter
        limit - The maximum number of results to retrieve.
        Returns:
        a list of the results
      • createQueryUpdateOrDelete

        int createQueryUpdateOrDelete​(String qlString,
                                      Map<String,​Object> params)
        Create an update or delete Query for executing a Java Persistence query language statement and execute the statement.
        Parameters:
        qlString - a Java Persistence query string
        params - Map of parameters to bind an argument to a named parameter
        Returns:
        the number of entities updated or deleted
      • createNamedQuerySelect

        List<E> createNamedQuerySelect​(String name,
                                       Class<E> entityClass,
                                       Map<String,​Object> params)
        Create a SELECT TypedQuery for executing a Java Persistence query language named query. The select list of the query must contain only a single item, which must be assignable to the type specified by the resultClass argument. Execute the query and return the query results as an untyped List.
        Parameters:
        name - the name of a query defined in metadata
        entityClass - the type of the query result
        params - Map of parameters to bind an argument to a named parameter
        Returns:
        a list of the results
      • createNamedQueryUpdateOrDelete

        int createNamedQueryUpdateOrDelete​(String name,
                                           Class<E> entityClass,
                                           Map<String,​Object> params)
        Create a update or delete TypedQuery for executing a Java Persistence query language named query. The select list of the query must contain only a single item, which must be assignable to the type specified by the resultClass argument. Execute the statement.
        Parameters:
        name - the name of a query defined in metadata
        entityClass - the type of the query result
        params - Map of parameters to bind an argument to a named parameter
        Returns:
        the number of entities updated or deleted