This part seems quite wrong:
Property contentProp = do_audit.getType().getProperty("content");
DataObject contentDO = dobj.createDataObject(contentProp,
contentProp.getType());
contentDO.getList("userref").add(dobj);
do_audit.setDataObject(contentProp, contentDO);
I think it should be something like this:.
DataObject contentDO = do_audit.createDataObject("content");
contentDO.getList("userref").add(dobj);
Frank.
Nicolas Nobelis <[email protected]> wrote on 08/21/2009
12:20:49 PM:
> Greetings !
>
> Sorry for this huge post but I'm completely stuck with SDO ...
>
> I am using Tuscany tuscany-sdo-impl-1.1.1.jar with JDK 6.
>
> I have a XML schema audit.xsd :
> <xsd:schema targetNamespace="http://example.com/request/1.0"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:req="http://example.com/request/1.0"
> xmlns:um="http://example.com/usermodel/1.0"
> xmlns="http://example.com/request/1.0"
> elementFormDefault="qualified">
>
> <xsd:include schemaLocation="usermodel.xsd"/>
>
> <xsd:complexType name="auditlog">
> <xsd:all>
> [...]
> <xsd:element name="content" type="content" minOccurs="0"
> maxOccurs="1"/>
> </xsd:all>
> </xsd:complexType>
>
> <xsd:complexType name="content" mixed="false">
> <xsd:sequence minOccurs="0" maxOccurs="unbounded">
> <xsd:element ref="um:userref" minOccurs="0"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
>
> This schema references usermodel.xsd which contains :
> <xsd:complexType name="umref">
> <xsd:all>
> <xsd:element name="name" type="xsd:string" minOccurs="1"
> maxOccurs="1"/>
> </xsd:all>
> </xsd:complexType>
> <xsd:complexType name="userref">
> <xsd:complexContent>
> <xsd:extension base="um:umref">
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> So I give these two schemas to the XSDHelper through the "define"
> method. From the same HelperContext, I create a userref DO :
> dobj = getDataFactory().create("http://example.com/usermodel/1.0",
> "userref");
> I set its property :
> dobj.setString("name", "blabla");
>
> Then, I take an AuditLog DataObject do_audit and I add dobj as the
> attribute "content" :
>
> Property contentProp = do_audit.getType().getProperty("content");
> DataObject contentDO = dobj.createDataObject(contentProp,
> contentProp.getType());
> contentDO.getList("userref").add(dobj);
> do_audit.setDataObject(contentProp, contentDO);
>
> Finally, from the same HelperContext, I save the do_audit object :
>
> getXMLHelper().save(content, "http://example.com/request/1.0",
"auditlog");
>
> and I get :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <req:auditlog xmlns:req="http://example.com/request/1.0"
> xmlns:um="http://example.com/usermodel/1.0">
> [...]
> <req:content>
>
> <um:userref>org.apache.tuscany.sdo.impl.dynamicdataobjecti...@2c47d7
> (eClass: org.apache.tuscany.sdo.impl.classi...@1e2a543 (name: userref)
> (instanceClassName: null) (abstract: false, interface: false))
> </um:userref>
> </req:content>
> </req:auditlog>
>
> Could anybody tell me why the address of the object is written and not
> its contents ?
>
> Thanks a lot for any tips or advice :)
> Best regards and a nice w.e. to all !
>
> Nicolas Nobelis
>
>
>
>