> class User {
> private long id;
[quoted text clipped - 27 lines]
> the getter in real life code (except when a field is only to be used in
> internal calculations).
There is, of course, the train of thought that most classes should not
expose getters. Instead, they should expose methods that do internally what
is necessary.
When using Hibernate, I prefer the direct field access style. It makes the
persistence-capable classes so much more natural.
-- Adam Maass
Oliver Wong - 11 May 2006 19:08 GMT
> When using Hibernate, I prefer the direct field access style. It makes the
> persistence-capable classes so much more natural.
Hibernate persists the states of objects.
By using direct field access, you'd be persisting the
implementation-state, as opposed to the publicly visible apparent state, of
the object.
Sometimes that's what you want, but sometimes it isn't.
- Oliver