From the course: Java Persistence with JPA and Hibernate
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
The repository pattern - JPA Tutorial
From the course: Java Persistence with JPA and Hibernate
The repository pattern
- [Instructor] Design patterns are all about clean code. The repository pattern is a design pattern for the persistence layer of an application. It abstracts your data store and enables your business logic to interact with it. You might wonder that Jakarta Persistence is itself a layer of abstraction that abstracts the data store, but the repository pattern is meant to offer a higher level of abstraction than that and hide all specific functions of the data store. The main purpose is to have all database access methods or logic for an entity in a single place called as a repository, and not have them scattered in different parts of your business logic. This makes business logic more reusable, as well as enables you to reuse certain queries or data access logic in general. It's very simple. You just need to create an interface for each of your entities, like the BookRepository in this example. This interface will have methods to perform read write operations like create, read, delete…