[hibernate-dev] Another @Access quandry

Hardy Ferentschik hardy at hibernate.org
Wed Mar 26 15:36:41 EDT 2014


On 26 Jan 2014, at 15:56, Sanne Grinovero <sanne at hibernate.org> wrote:

> But the original test represents a quite naturally looking example and
> it's hard to justify why that should be considered illegal; 

Because it is against the rules for the placement of @Access.
At least in my interpretation of the spec.

> Ignoring any annotation leads to waste of time and debugging
> frustration, so rather than silently discarding a mis-positioned
> annotation I'd prefer a fail-fast approach;

True. There are several bug reports  due to the fact that we ignore mapping information.
However, we never have taken all annotations into consideration. The approach has always
been to first determine where to look for annotations (per default based on the placement of
the @Id annotation) and then only consider annotations placed according to the discovered strategy.

I would assume there were two reasons for ignoring “wrongly” placed annotations:
- annotation processing time and the attempt to avoid accessing all fields and getters via reflection
- a considerable extra effort in coding to do proper processing and error handling

Personally I could imagine an option where we determine an default annotation placement and 
throw an exception if any mapping annotation is wrongly placed. If the option is disabled
we ignore (maybe log) the annotation.

> that said I think just
> applying them all - as long as there are no obvious conflicting
> annotations - would be even more user friendly and doesn't seem to
> violate any specific wording of the spec.

-1

—Hardy


More information about the hibernate-dev mailing list