Annotates a repository interface to be implemented by the container/runtime.
This class is a CDI bean-defining annotation when CDI is available.
Regardless of whether CDI or custom dependency injection is used, the
repository implementation must be made available to applications via the
jakarta.inject.Inject annotation.
For example,
@Repository
public interface Products extends DataRepository<Product, Long> {
@OrderBy("price")
List<Product> findByNameLike(String namePattern);
@Query("UPDATE Product SET price = price - (price * ?1) WHERE price * ?1 <= ?2")
int putOnSale(float rateOfDiscount, float maxDiscount);
...
}
@Inject
Products products;
...
found = products.findByNameLike("%Printer%");
numUpdated = products.putOnSale(0.15f, 20.0f);
The module Javadoc provides an overview of Jakarta Data.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | ANY_PROVIDER
Value for the |
| public static final String | DEFAULT_DATA_STORE
Value for the |
| Modifier and Type | Method and Description |
|---|---|
| public String | Returns: the name of a data store orDEFAULT_DATA_STORE.Optionally indicates the data store to use for the repository. |
| public String | Returns: the name of a Jakarta Data provider orANY_PROVIDER.Restricts the repository implementation to that of a specific Jakarta Data provider. |
| ANY_PROVIDER | back to summary |
|---|---|
| public static final String ANY_PROVIDER Value for the | |
| DEFAULT_DATA_STORE | back to summary |
|---|---|
| public static final String DEFAULT_DATA_STORE Value for the When running in a Jakarta EE profile or platform and the entity annotations
indicate a relational database, the default data store is the
Jakarta EE default data source, The default data store might require additional vendor-specific configuration, depending on the vendor. | |
| dataStore | back to summary |
|---|---|
| public String dataStore() Optionally indicates the data store to use for the repository. Precedence for interpreting the
The default value of this attribute is
| |
| provider | back to summary |
|---|---|
| public String provider() Restricts the repository implementation to that of a specific Jakarta Data provider. This is useful when multiple Jakarta Data providers support the
same type of entity annotation, in which case the provider attribute
clarifies which Jakarta Data provider must be used.
Jakarta Data providers must ignore The default value of this attribute is
| |