tuscany-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Viatcheslav Kuravskiy <kuravs...@googlemail.com>
Subject SDO Static Object
Date Wed, 10 Jun 2009 08:48:13 GMT
Hello to all!

How can I map a DataObject to a Java object? My situation is:

1) From person.xsd was generated Person.java, PersonFactory.java, 
PersonImpl.java and PersonFactory.java. XSD2JavaGenerator was used for it.

Here is person.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://www.example.org/person" 
xmlns:tns="http://www.example.org/person" elementFormDefault="qualified">

    <complexType name="Person">
        <sequence>
            <element name="Name" type="string"></element>
            <element name="Age" type="int"></element>
            <element name="id" type="int"></element>
        </sequence>
    </complexType>
</schema>

2) I have a RDB with a table PERSON and columns ID:integer, 
NAME:varchar, AGE:integer.

Here is a part from Config.xml:

    <Table tableName="PERSON" typeName="Person">
        <Column columnName="ID" primaryKey="true"/>
    </Table>

    <Command name="getFirstPerson" SQL="select * from PERSON where ID=1" 
kind="Select"/>


3) I do:

        HelperContext hc = HelperProvider.getDefaultContext();
        PersonFactory.INSTANCE.register(hc);

        DAS das = DAS.FACTORY.createDAS(getConfig(configFile));

        Command getPerson = das.getCommand("getFirstPerson");
        DataObject root = getPerson.executeQuery();

        DataObject p1 =  root.getDataObject("Person[1]");

        Person p2 = PersonFactory.INSTANCE.createPerson();

        p2 = (Person) p1; // Here I have exception


Can somebody help me to solve this problem?


Best regards,
V.Kuravskiy

Mime
View raw message