Return-Path: Delivered-To: apmail-tuscany-user-archive@www.apache.org Received: (qmail 59895 invoked from network); 15 Jun 2009 11:34:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Jun 2009 11:34:52 -0000 Received: (qmail 88711 invoked by uid 500); 15 Jun 2009 11:35:03 -0000 Delivered-To: apmail-tuscany-user-archive@tuscany.apache.org Received: (qmail 88649 invoked by uid 500); 15 Jun 2009 11:35:02 -0000 Mailing-List: contact user-help@tuscany.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@tuscany.apache.org Delivered-To: mailing list user@tuscany.apache.org Received: (qmail 88641 invoked by uid 99); 15 Jun 2009 11:35:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2009 11:35:02 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kelvingoodson@gmail.com designates 209.85.218.226 as permitted sender) Received: from [209.85.218.226] (HELO mail-bw0-f226.google.com) (209.85.218.226) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2009 11:34:54 +0000 Received: by bwz26 with SMTP id 26so3073714bwz.20 for ; Mon, 15 Jun 2009 04:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=bKxJYo93hFk4RQuIyfyeonrL4ICl38UII+o9NqSWYDE=; b=E3BXC2cO/yXRBEHVIO7qrZAB1cmTfqycUokkrjqIkt6wm6ammiziZ/bXOGIpgvB2wQ 82gBxn/FrbTbOyu/2XfmhVHnNcYP4G0lr+AqD9eF8oOmMwek6FLyTycQ26HbcfVrodV1 VKj6I+NWKPYHuSWSRGMrcmTZQQ450P0ENU7XQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=n7a7iwxJbto32LOHhgROKPWb7f+kT2yW6YnlMdmy1G+V/8sKFnODNcp1VePDxvxLtM jdrFyectxyiD4nKk+2WOiDiYIOLUNGgn0fJh5M3r03W57zU89NCqDIepXC4+L8eX28Iq 1rGNUnzlNdalTZxK8NOt0f1es/1ji9lzCL8QE= MIME-Version: 1.0 Received: by 10.204.56.4 with SMTP id w4mr6983571bkg.17.1245065671413; Mon, 15 Jun 2009 04:34:31 -0700 (PDT) In-Reply-To: <4A363095.40707@gmail.com> References: <9deac9fd0906100256i135cd1ahf729a33638b10b35@mail.gmail.com> <4A3297F6.1040702@gmail.com> <9deac9fd0906150327p28500d86x6016417a46023cf8@mail.gmail.com> <4A363095.40707@gmail.com> Date: Mon, 15 Jun 2009 12:34:26 +0100 Message-ID: <9deac9fd0906150434u30f4db3bva3f769cc23d40632@mail.gmail.com> Subject: Re: SDO Static Object From: kelvin goodson To: user@tuscany.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org OK, so I think you may have the metadata registered twice perhaps, once dynamically and once statically. I say this because the class you have an instance of is DynamicDataObjectImpl and not AnyTypeDataObjectImpl. I wonder whether a dynamic registration of the schema is masking the registration of the static classes? Kelvin. 2009/6/15 Viatcheslav Kuravskiy : > I post my code once again: > > =A0 =A0 =A0 =A0HelperContext hc =3D HelperProvider.getDefaultContext(); > =A0 =A0 =A0 =A0PersonFactory.INSTANCE.register(hc); > > =A0 =A0 =A0 =A0DAS das =3D DAS.FACTORY.createDAS(getConfig(configFile)); > > =A0 =A0 =A0 =A0Command readPerson =3D das.getCommand("getFirstPerson"); > =A0 =A0 =A0 =A0DataObject root =3D readPerson.executeQuery(); > > =A0 =A0 =A0 =A0Person p =3D PersonFactory.INSTANCE.createPerson(); > > =A0 =A0 =A0 =A0p =3D (Person)root.getDataObject("Person[1]"); > > The exception is: > > java.lang.ClassCastException: > org.apache.tuscany.sdo.impl.DynamicDataObjectImpl cannot be cast to > sdo.Person > > -- > Best regards, > V.Kuravskiy > > kelvin goodson wrote: >> >> Could you please supply some detail of the exception. >> >> I note that in some of the postings above the schema =A0seems to have a >> type of "erson" - Similarly there are element names of "ame", "ge" and >> "d" =A0- is this what you have or just a cut and paste error? >> >> Kelvin. >> >> 2009/6/12 Viatcheslav Kuravskiy : >>> >>> kelvin goodson wrote: >>>> >>>> I'm guessing your exception is a ClassCastException because the actual >>>> class is AnyTypeDataObjectImpl, and not PersonImpl. =A0For 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 : >>>> >>>>> 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 fo= r >>>>> it. >>>>> >>>>> Here is person.xsd: >>>>> >>>>> >>>>> >>>> targetNamespace=3Dttp://www.example.org/person" >>>>> xmlns:tns=3Dttp://www.example.org/person" elementFormDefault=3D"quali= fied"> >>>>> >>>>> =A0 >>>>> =A0 =A0 >>>>> =A0 =A0 =A0 =A0 >>>>> =A0 =A0 =A0 =A0 >>>>> =A0 =A0 =A0 =A0 >>>>> =A0 =A0 >>>>> =A0 >>>>> >>>>> >>>>> 2) I have a RDB with a table PERSON and columns ID:integer, >>>>> NAME:varchar, >>>>> AGE:integer. >>>>> >>>>> Here is a part from Config.xml: >>>>> >>>>> =A0 >>>>> =A0 =A0 >>>>> =A0
>>>>> >>>>> =A0>>>> kind=3Delect"/> >>>>> >>>>> >>>>> 3) I do: >>>>> >>>>> =A0 =A0 HelperContext hc =3D HelperProvider.getDefaultContext(); >>>>> =A0 =A0 PersonFactory.INSTANCE.register(hc); >>>>> >>>>> =A0 =A0 DAS das =3DAS.FACTORY.createDAS(getConfig(configFile)); >>>>> >>>>> =A0 =A0 Command getPerson =3Das.getCommand("getFirstPerson"); >>>>> =A0 =A0 DataObject root =3DetPerson.executeQuery(); >>>>> >>>>> =A0 =A0 DataObject p1 =3Droot.getDataObject("Person[1]"); >>>>> >>>>> =A0 =A0 Person p2 =3DersonFactory.INSTANCE.createPerson(); >>>>> >>>>> =A0 =A0 p2 =3DPerson) p1; // Here I have exception >>>>> >>>>> >>>>> Can somebody help me to solve this problem? >>>>> >>>>> >>>>> Best regards, >>>>> V.Kuravskiy >>>>> >>>>> >>>> >>> Actually I did the same thing from this example: >>> http://tuscany.apache.org/workingwithstaticdataobjects.html >>> >>> Just >>> >>> SDOUtil.registerStaticTypes(CustomerFactory.class); >>> >>> was changed with >>> >>> HelperContext hc =3D HelperProvider.getDefaultContext(); >>> PersonFactory.INSTANCE.register(hc); >>> >>> But unfortunately it's not working. >>> >>> V.Kuravskiy >>> >>> >> >