Module jakarta.data

Interface BasicRepository<T,K>

Type Parameters:
T - the type of the primary entity class of the repository.
K - the type of the unique identifier attribute of the primary entity.
All Superinterfaces:
DataRepository<T,K>
All Known Subinterfaces:
CrudRepository<T,K>

public interface BasicRepository<T,K> extends DataRepository<T,K>

A built-in repository supertype for performing basic operations on entities.

The type parameters of BasicRepository<T,K> capture the primary entity type (T) for the repository and the type of the unique identifier attribute (K) of the primary entity type.

The primary entity type is used for repository methods, such as countBy... and deleteBy..., which do not explicitly specify an entity type.

Example entity:

 @Entity
 public class Employee {
     @Id
     public int badgeNumber;
     public String firstName;
     public String lastName;
     ...
 }
 

Example repository:

 @Repository
 public interface Employees extends BasicRepository<Employee, Integer> {

     boolean deleteByBadgeNumber(int badgeNum);

     ...
 }
 

Example usage:

 @Inject
 Employees employees;

 ...

 Employee emp = ...
 emp = employees.save(emp);

 boolean deleted = employees.deleteByBadgeNumber(emp.badgeNum);

 PageRequest<Employee> pageRequest = PageRequest.of(Employee.class).size(25).sortBy(Sort.asc("name"));
 Page<Employee> page = people.findAll(pageRequest);
 

The module Javadoc provides an overview of Jakarta Data.