Are persistence annotations in domain objects a bad practice?

前端 未结 8 938
青春惊慌失措
青春惊慌失措 2021-02-01 15:09

I realize that persistence frameworks such as Morphia and Hibernate rely on annotations on domain objects to do their magic. At some level, it seems to me that this is insertin

8条回答
  •  面向向阳花
    2021-02-01 15:24

    In my opinion there's no need to duplicate the domain objects to be able to seperate them from your persistance layer. It works duplicate code in hand and it's perfectly doable by using those same objects as DTO's. If necessary you can always use seperate classes if it's needed, but I wouldn't make it a rule of thumb, it 'll cost you time and we all know time is valuable.

提交回复
热议问题