I'm guessing your exception is a ClassCastException because the actual class is AnyTypeDataObjectImpl, and not PersonImpl. For the DAS to create instances of your generated class it would a) have to be using the default helper context, and b), understand that Person objects are from the http://www.example.org/person namespace. Perhaps someone who is familiar with DAS could take a look at this?
Kelvin. 2009/6/10 Viatcheslav Kuravskiy <[email protected]>: > 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 >
