08-10-07 12:11 PM
I came across a particular situation that impacts on the wording for the te=
xt=20
to go in the spec for precedence of XML and Annotation metadata.
I have :-
@PersistenceCapable
public class MyClass
{
@PrimaryKey
long id;
@Persistent
String name;
..
}
Question : Should we allow users to override the setting of "primary-key" i=
n=20
XML when it is defined in the annotations ? or should the setting in the=20
annotations for which field(s) are PK be fixed ?
The problem comes in how to merge the value in annotations and value in XML=
=2E=20
With XML, due to the DTD/XSD, there will always be a value for "primary-key=
".=20
With annotations it will have a value only if the user provided one.
If we allow overrides via XML, then we must just take any value from XML=20
(since there is always a value when read in). This impacts on what a user h=
as=20
to specify when overriding any information in XML. For example, if the user=
=20
wanted to override some info about the above class they would have to speci=
fy=20
the "primary-key" values correctly to make sure that they were respected (i=
f=20
they didn't specify the "primary-key" element then they get the DTD default=
=20
of "false"!) hence duplicate definition.
My conclusion is that we should prohibit the override of "primary-key" when=
=20
the annotations have explicitly set the value. If annotations haven't set t=
he=20
value then the value in XML should be respected.=20
Anyone disagree ?
=2D-=20
Andy =C2=A0(Java Persistent Objects - http://www.jpox.org)
[ Post a follow-up to this message ]
|