I have a Tomcat app that uses Entities that are autogenerated from Eclipse/JPA. I then have hand coded DAOs that interface to the database.
I see a significant benefit to keeping the Entities simple. e.g. the spec says it must have a blank constructor. Leaving them alone means I can regenerate them if the database schema changes. But I am being tempted to extend them.
A couple of issues...
If I create a new entity, I would like certain fields to have non-null values. If I have an empty constructor, I can't do it there. e.g. status='New', Date created = new Date() etc.
I realize I could use a Factory. But should that live say within the DAO instead? e.g. DAO.getNewObject()?
Similarly, if I want to use test or validation logic, where does that go? e.g. completeness score = if name, address, phone, etc are filled out? Should this kind of thing live in the DAO? or the Entity? or something else?
Should I have a new Class that extends the Entity and put the logic in there?
Is think kind of architectural stuff covered somewhere?