Should raw Hibernate annotated POJO's be returned from the Data Access Layer, or Interfaces instead?

后端 未结 2 1975
北荒
北荒 2021-01-21 17:47

I understand separating the data layer objects (DAOs) in their own layer that abstracts the data access logic and data source specifics from service and business layers as outli

2条回答
  •  一生所求
    2021-01-21 18:21

    Annotations have one drawback of coupling some framework knowledge with Java objects. That's the price you pay for not having separate metadata definitions. POJOs still remain POJOs, though, and from practical standpoint I see no good reason to complicate design just because of annotations.

    Lets think, if you would use XML mappings, would you even have that concern? Most likely - not. So pay the penalty and move on; and in unlikely case if you will be changing your persistence framework - you will go ahead and remove those annotations. In all cases they should have no side effects on your code outside of your DAO layer.

    Just my 2 cents...

提交回复
热议问题