Spring Data
uses repository pattern, with two bounded type parameters T, ID.
public
interface Repository<T, ID> {
}
T: Domain
type that the repository manages. For ex, Employee, Address, Organization etc.,
ID: Type
of the id of the entity the repository manages
@Entity public class Employee { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int id; .... .... }
We can define EmployeeRepository like below.
public interface EmployeeRepository extends CrudRepository<Employee, Integer> { }
'CrudRepository'
interface is provided by spring data which extends Repository interface and
provide methods to create, read, update and delete records from database.
No comments:
Post a Comment