Hi Frank and thanks for your quick answer.
My XSD looks exactly like your example and, with property as my
commonj.sdo.Property object representing test, I get test.isNullable() =
true. In fact, the actual name of my element is numero_cheque (I used
test as an example of my situation).
Here is its exact definition: <element nillable="true"
name="numero_cheque" type="string"></element>
I tried different things and it worked well:
Property property = ((org.apache.tuscany.sdo.impl.DataObjectImpl)
builtObject).getType().get("numero_cheque"); -> returns a valid property
object
int featureID = builtObject.eDerivedStructuralFeatureID(property);
-> returns 8
Maybe I'm not getting down to the Accessor.create() code in fact.
Here is my test code and the associated results:
commonj.sdo.Property myProperty =
((org.apache.tuscany.sdo.impl.DataObjectImpl)
builtObject).getType().getProperty("numero_cheque");
boolean nullable = myProperty.isNullable();
boolean openContent = myProperty.isOpenContent();
boolean readOnly = myProperty.isReadOnly();
boolean a = builtObject.isSet(myProperty);
builtObject.set(myProperty, null);
boolean b = builtObject.isSet(myProperty);
builtObject.set(myProperty, "");
boolean c = builtObject.isSet(myProperty);
And I get:
nullable = true
openContent = readOnly = false
a = b = false
c = true
Jawad
Le 08/09/10 20:42, Frank Budinsky a écrit :
Even though you say that the "test" property is nillable in the XSD,
the behavior you're describing really sounds like it is not. Are you
sure the XSD is valid and the element is nillable? The element should
look something like this:
<xsd:element name="test" type="..." nillable="true"/>
If you're getting down to the Accessor.create() code, it implies that
there is no property named "test" in the type, which seems to imply
that there's something wrong with your metadata.
Frank
Jawad - CitizenPlace <[email protected]> wrote on 09/08/2010
01:05:16 PM:
> [image removed]
>
> Tuscany SDO and xsi:nil
>
> Jawad - CitizenPlace
>
> to:
>
> user
>
> 09/08/2010 01:06 PM
>
> Please respond to user
>
> Hi everyone.
>
> I'm having a hard time trying to add xsi:nil=true to some properties
> in the generated instances.
>
> I have read that doing that was as simple as setting the property to
null.
> Let's consider that I have a DataObjectBase object called
> "builtObject". My property is called "test" and is set to nillable
in my XSD.
>
> If I write builtObject.set("test", null), the property is not set as
> expected : if I then call builtObject.isSet("test"), I get 'false'
> where as I should get true as stated in the specification (test=null
> + isSet(test) = true ==> xsi:nil). Logically, the returned XML
> simply ignores the property while I need it to be present and set to
null.
>
> I jumped into the source code of SDO and I got to these lines:
> public static void set(DataObject dataObject, String path, Object
value)
> {
> Property property = dataObject.getType().getProperty(path);
> if (property != null)
> {
> dataObject.set(property, value);
> }
> else
> {
> Accessor.create((EObject)dataObject, path,
> value).setAndRecyle(value);
> }
> }
>
> I do not really understand what is the Accessor used for.
> --
> Jawad, pour l'équipe CitizenPlace
> Tél : +33 9 52 31 26 45
> Mobile : +33 6 20 08 16 13
> E-mail : [email protected]
--
*Jawad, * pour l'équipe CitizenPlace
Tél : +33 9 52 31 26 45
Mobile : +33 6 20 08 16 13
E-mail : [email protected] <mailto:[email protected]>