A repository is an interface annotated with jakarta. that defines
operations on entities. Entities represent data in the persistent store.
In Domain-driven design, a repository participates in the domain but abstracts away storage
and infrastructure details.
Repository interfaces can optionally inherit from built-in interfaces within this package,
jakarta.data.repository.DataRepository - root of the hierarchy, allows the entity type to be specified as a type parameter.jakarta.data.repository.BasicRepository - provides common find, delete, and save operations.jakarta.data.repository.CrudRepository - extends the BasicRepository to add jakarta.data.repository.CrudRepository#insert(java.lang.Object)
and jakarta.data.repository.CrudRepository#update(java.lang.Object) operations.Repository interfaces can also define their own lifecycle methods using the
jakarta., jakarta., jakarta., and jakarta. annotations,
as well as a variety of other methods following the Query by Method Name pattern,
the Parameter-based Conditions pattern, and the jakarta. annotation.
The module Javadoc provides an overview of Jakarta Data.
| Modifier and Type | Interface and Description |
|---|---|
| public interface | BasicRepository<
the type of the primary entity class of the repository. T, the type of the unique identifier attribute of the primary entity. K>A built-in repository supertype for performing basic operations on entities. |
| public interface | CrudRepository<
the type of the primary entity class of the repository. T, the type of the unique identifier field of property of the primary entity. K>A built-in repository supertype for performing Create, Read, Update, and Delete (CRUD) operations. |
| public interface | DataRepository<
the type of the primary entity class of the repository. T, the type of the unique identifier field of property of the primary entity. K>A built-in repository supertype that is the root of all other built-in repository supertype interfaces. |
| Modifier and Type | Annotation and Description |
|---|---|
| public @interface | By
Annotates a parameter of a repository method, specifying a mapping to a persistent field:
|
| public @interface | Delete
Lifecycle annotation for repository methods which perform delete operations; alternatively, annotates a repository method as a parameter-based automatic query method which deletes entities. |
| public @interface | Find
Annotates a repository method returning entities as a parameter-based automatic query method. |
| public @interface | Insert
Lifecycle annotation for repository methods which perform insert operations. |
| public @interface | OrderBy
Annotates a repository method to request sorting of results. |
| public @interface | |
| public @interface | Query
Annotates a repository method as a query method, specifying a query written in Jakarta Data Query Language (JDQL) or in Jakarta Persistence Query Language (JPQL). |
| public @interface | Repository
Annotates a repository interface to be implemented by the container/runtime. |
| public @interface | Save
Lifecycle annotation for repository methods which conditionally perform insert or update operations. |
| public @interface | Update
Lifecycle annotation for repository methods which perform update operations. |