Answer the question
In order to leave comments, you need to log in
Entity Interface - an antipattern?
Greetings!
Life forces us to separate the DAO level into a separate artifact, for ease of migration to another data store.
I found that models (entity) often have a lot of hung annotations that are not applicable in the new repository and its ORM.
Since entities are used at the service level, which remains generic, accordingly, there is an idea to separate interfaces from the entity and use them at the service level.
Is this a normal implementation or is it still not in line with the idea of beauty?
Answer the question
In order to leave comments, you need to log in
For full portability between different data sources, it is necessary that the dao methods return DTOs, and not stored entities. It is desirable to make DTO-shki immutable and put it in dao-api. In the implementation of dao, you will also need to make a mapper between entities and dto-shki.
Life forces us to separate the DAO level into a separate artifactWell, pick it out. Then, when you migrate completely, you still have to do a little refactoring. Fix that as well. And there you look and the situation will be different.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question