Tom Anderson wrote:
On Wed, 30 Dec 2009, Lew wrote:
Entity objects are not really meant for a lot of manipulation outside the
JPA context or by application logic.
No, no, no. JPA is a mechanism, not a policy - JPA entities are not 'meant'
for anything. You might think it's a good idea to use JPA entities that
way, but it's something i'd disagree very strongly with you over - what
you're advocating is an Anemic Domain Model, and it's a bad thing (Martin
Fowler says so, so it must be true! :) ):
http://martinfowler.com/bliki/AnemicDomainModel.html
I'm in general agreement with what's said in that link. However, in the
context of JPA, I myself don't think of the entity classes by themselves
as defining the domain layer in its entirety. I don't think of JPA
entity classes as being domain classes at all, not by definition. Some
happen to correspond to domain classes, some don't. To me JPA entity
classes are fine-grained Java mappings to RDBMS tables, and that's about
it. They are at the same level as iBatis mapping files.
I tend to think of DAOs, which map to the real domain classes, as being
the domain layer. Some JPA entities happen to have a 1:1 mapping to a
domain class - many do not, and really aren't more than value objects or
DTOs.
Interesting. Are you essentially using JPA entities as behind-the scenes
The real romance is out ahead and yet to come. The computer revolution
hasn't started yet. -- Alan Kay