Hey Gabriel, sorry for the delayed response.
Ideally, each entity has its repository, meaning that if you have a Car entity, you would typically have a CarRepository. However, Jakarta Data does not enforce this structure. You are free to design repositories that best suit your domain. For example, instead of CarRepository, you might name it GarageRepository if it better represents the concept of managing a collection of cars. The specification does not impose naming restrictions.
Additionally, an entity is not limited to a single repository interface. You can define multiple repositories for the same entity, each serving different purposes. For instance:
- A
CarRepository handling standard CRUD operations.
- A
CarSearchRepository optimized for querying cars with specific filters.
Jakarta Data also allows repositories to support multiple data sources, meaning the same repository can work with both SQL and NoSQL databases:
- For SQL databases, you use Jakarta Persistence annotations.
- For NoSQL databases, you use Jakarta NoSQL annotations.
For more details and examples, you might find this article helpful:
Persisting Data with Jakarta EE and Jakarta Data