Both the JPA spec and the OpenJPA doc implies that if I have annotations
on a field and a definition for the field in my orm.xml file, the
annotations for that field will be ignored and only the XML definition
will be used.  Is that correct?

I believe I've found a situation where that isn't exactly true, and I'd
like to understand whether this is a bug or a misunderstanding.

I prefer to define "logical" annotations and "physical" XML.  This
effectively means that many annotations would be ignored, but I like
seeing the logical relationships defined in the entity class.

I have numerous "OneToMany" annotations defined in my entities, with the
corresponding physical XML.  What I accidentally discovered is that I
had some entities where I had added "(fetch = FetchType.EAGER)" to the
annotation, but I never added the corresponding setting to the XML.  I
found those relationships were being eagerly fetched.  When I tried
removing the "fetch" setting in the annotation, the relationship became
lazily fetched.  So, although the docs say that the overriding is at the
"field" level, and not the "piece of a field" level, it appears that the
settings in the annotation and the XML have been "merged" in some way.

Is the "fetch" setting an exception to the rule as I understand it?  Are
there other exceptions to this?  Is this a bug, according to the spec?

Reply via email to