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

后端 未结 2 1979
北荒
北荒 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:20

    Both ;) I'm pretty ambivalent--I prefer interfaces, it's just easier to mock, use across non-Hibernate systems, etc. but in my case I've usually needed to provide an external API with datatypes, so it's almost always made sense. That, and I generate the interfaces automatically, so I don't have to actually do anything.

    For isolated systems with no external API requirements, or if you never need the types outside of Hibernate, I'm not convinced it really matters all that much, although the purists will have my head on a pike for saying so (and they're arguably correct).

提交回复
热议问题