1
1
1nd1go2011-08-15 15:00:18
Java
1nd1go, 2011-08-15 15:00:18

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

3 answer(s)
D
dborovikov, 2011-09-01
@1nd1go

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.

Z
zizop, 2011-08-16
@zizop

Life forces us to separate the DAO level into a separate artifact
Well, 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.

Z
Zamorozka, 2011-08-16
@Zamorozka

I didn’t quite understand the question, do you want to abandon the DAO?
If so, then for example, they did it in spring roo, all DAO methods are static and belong to the entity class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question