I'm proposing an alternate way of integrating with
Hibernate trough the use of user types. These provide a
cleaner way for users of the library to describe their
domain objects in hibernate mapping files.
The patch provides an example of this approach for
com.domainlanguage.time.TimeInterval.
Although the user types themselves use reflection onto
private fields in the time and money objects which
breaks encapsulation just as much as going through
private getters this use is hidden in components that
in a way extend the domain model into Hibernate. This
is visible in my example where the usertype for
TimeInterval exposes two properties, start and end for
use in HQL.
The biggest benefit of this approach is ofcourse that
users dont need to dig inside the domain objects to
find the fields that need to be persisted, which should
be part of the implementation details and not visible
externally. Users will still need to name columns and
give them the right type if they're designing the
tables themselves.
Also, it gets rid of the getForPersistentMapping-methods.
The patch
Logged In: YES
user_id=753540
Indeed, this is the proper way to Hibernate. I'm working on
a CompositeUserType that corresponds to the Money class, and
I'l post that as a patch, a well.