This is something I've often thought about in regards to ANY ORM. iBATIS
and Hibernate. I've come up with two solutions.
One, add behavior to your POJOs, and ask that consumers of your classes
don't use the getters/setters which iBATIS uses.
Two, Create behavior rich classes which hold/own the data-only POJOs.
The data-only POJO's contained are the implementation details of the
behavior rich objects. In other words, treat your persisted data as
primitives, and wrap them appropriately.
There may be a third possibility, but I don't know how well iBATIS (or
Hibernate) would handle it... Have the persistence read/write otherwise
hidden data, and have the POJOs implement the domain logic normally,
without regards to persistence.
________________________________
From: Cihat.altuntas [mailto:[EMAIL PROTECTED]
Sent: Monday, April 02, 2007 6:20 AM
To: [email protected]
Subject: Anemic Domain Model and iBatis
What do you think about iBatis POJOs and Anemic Domain model
that martin fowler describes :
http://www.martinfowler.com/bliki/AnemicDomainModel.html
iBatis uses POJOs like anemic domain model. Most of the classes
only have getter and setter methods. Is this domain model or just DTO or
Value Objects? Where do you put your core domain logic ? is iBatis
suaitable for Rich Domain models? I want to see your opinions about this
subject?