|
|
|
|
|
by AgentIcarus
4568 days ago
|
|
I agree with the author that the Single Responsibility Principle is being violated with all these annotations, but I disagree that the resolution is to move the annotations into hbm.xml files (or similar). I would, in the limited example given, prefer to have a 'storage' POJO (annotated with the hibernate annotations), and an 'API' POJO (annotated with the JSON and XML perhaps).
Then it seems to make sense that if you're changing the underlying storage you would update the storage POJO. I very rarely want to return the exact object as stored in my database to the API layer - there's business logic and the like that needs to be applied, and transforming the object into something the next layer requires means you can generally implement tighter interfaces. |
|