I'd normaly prefer field access but page 564 of
"Java Persistence with Hibernate" states that this is not such a good idea for the identifier property:
Quote:
As long as you access only the database identifier property, no
initialization of the proxy is necessary. (Note that this isn’t true if you map the
identifier property with direct field access; Hibernate then doesn’t even know that
the getId() method exists. If you call it, the proxy has to be initialized.)
But on page 70 it's written that
Quote:
If you placed the @Id annotation
on the getId() method, you’d enable access to properties through getter and setter
methods by default. Hence, all other annotations are also placed on either
fields or getter methods, following the selected strategy.
What me bothers is the
"all other annotations are also placed" part? Is this only the default behaviour or cann't i mix setter-access and field access at all?
/Stephan