> Am I understanding you correctly? Your entities have
> references back
> to the DAO's ?
>
> Your Entities should be simple POJO's, just getters +
> setters and some
> JPA2 annotations. Lazy loading of lists etc. is done
> automatically by
> the jpa2 container,
> if you haven't detached the entity.
Yes, my entities have references to Repository interfaces (not implementation classes), which are part of the domain model. Repository is a pattern similar to DAO, so I was using DAO in my examples to simplify things.
If you limit entities to being simple POJOs with only getters and setters, you're creating a pretty anemic model, as discussed here:
http://martinfowler.com/bliki/AnemicDomainModel.html
If you want to create a richer domain model, I believe exposing additional Repository or DAO methods through your entities (e.g. Site.getActiveUsers() exposing UserDAO.findByStatus()) is not a bad idea. If people disagree, I'm open to that, but I'd like to know their reasoning.
[Message sent by forum member 'theodan']
http://forums.java.net/jive/thread.jspa?messageID=396387