I have managed to resolve all my problems with XML --> JAVA --> (JDO) Database. Here are the bugs that I discovered and the work arounds? This is some what of post mortem.
I have my project working in multiples app servers/database configurations. Basically I got everything to work by having to setup a mapping.xml for XML and one for JDO.  I will add these to the Castor bug report.
 
1) Castor not being able to resolve a relative mapping.xml file in database.xml. This works fine for Tomcat 4.2.x but not for WebSphere 5.x. You should probabely use the full classpath of the mapping resource in the database.xml.
Working example:
-----------------------------------------------------------------------------------------
<database name="ods" engine="db2">
   <jndi name="java:comp/env/jdbc/ods"/>
   <!-- note this is not an absolutely path but the full path to the resource -->
   <mapping href=""/>
</database>
-----------------------------------------------------------------------------------------
 
2)  Self-referential relationship work around. Castor does support this for XML but not for JDO. For JDO you have to programmatically manage the relationship.
This is also the reason why the mapping files have to be different. For JDO you don't want CASTOR to store or retreive the classes. If  CASTOR sees a class descriptor it will try and load the class. I am not sure if this is a BUG.
 
Example working configuration
XML.
<class name="com.opendemand.jdo.WebResource" auto-complete="false" identity="webResourceId" key-generator="HIGH-LOW" >
  <description>Default mapping for class com.opendemand.jdo.WebResource</description>
   <map-to xml="web-resource" />
:
    <field name="webResources" type="com.opendemand.jdo.WebResource"
        required="false" direct="false" collection="arraylist"
        get-method="getWebResources" set-method="addWebResource" >
       <bind-xml name="web-resource" node="element" auto-naming="deriveByClass" transient="false" />
    </field>
</class>
JDO
Just don't include the field element. You can't use sql transient="true"
 
3) Bind XML transient="true" bug. The field validator will give a class cast exception or go into a recursive loop. The recursive loop may be fixed in CVS.  I didn't have time to retest Keith's fix.
 
Example working configuration:
XML
  Just don't include the field element.
JDO.
  You can just include it.
 
4) Castor JDO set-method bug. Castor JDO doesn't like it when the set-method doesn't take an array or collection. It complains that method doesn't exists. It works fine for Castor XML.
 
Example working configuration:
XML:
<field name="responseHeaders"
    type="com.opendemand.jdo.ResponseHeader" required="false"
    direct="false" transient="false" collection="arraylist"
    get-method="getResponseHeaders" set-method="addResponseHeader" lazy="false" >
   <bind-xml name="response-headers" node="element" auto-naming="deriveByClass"/>
</field>
JDO:
 <field name="responseHeaders"
    type="com.opendemand.jdo.ResponseHeader" required="false"
    direct="false" transient="false" collection="arraylist"
    get-method="getResponseHeaders" set-method="setResponseHeaders" lazy="false" >
    <sql many-key="web_resource_id" dirty="ignore" />
</field>
 
5) Object modification timestamp exception bug. This took me a long time to figure this one out. If you implement the TimeStampable interface and you have cache-type="NONE" for a dependent object, CASTOR thinks that it should be in the cache.
 
Example working configuration.
    In the class file just don't implement the TimeStampable.
 
6) Castor just extremely slow for transactions with lots of objects.
Fix:
    Added a SequencedHashtable to org.exolab.castor.persist.TransactionContext .  This fix gave me a 10x performance increase for loading a JDO object.
 
 
 
 
----- Original Message -----
From: "Keith Visco" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, October 04, 2003 5:10 AM
Subject: Re: [castor-dev] CASTOR no bind-xml element for a field

>
> Hi Stephen,
>
>
> I modified org.exolab.castor.xml.FieldValidator
>
> See details from CVS here:
>
>
http://project.exolab.org/cgi-bin/viewcvs.cgi/castor/src/main/org/exolab/castor/xml/FieldValidator.java?cvsroot=castor
>
> --Keith
>
> Stephen Ince wrote:
> >
> > Keith,
> >    Thanx. What files did you change? Download the cvs src? I see that in CVS
> > org.exolab.castor.xml.util.XMLClassDescriptorImpl has a timestamp of 10
> > days.
> >
> > Steve
> >
> > ----- Original Message -----
> > From: "Keith Visco" <
[EMAIL PROTECTED]>
> > To: <
[EMAIL PROTECTED]>
> > Sent: Friday, October 03, 2003 6:43 PM
> > Subject: Re: [castor-dev] CASTOR no bind-xml element for a field
> >
> > >
> > > Stephen,
> > >
> > > I checked in a quick patch to the CVS so that the FieldValidator will
> > > ignore transient fields...can you give that a shot.
> > >
> > > --Keith
> > >
> > > -----------------------------------------------------------
> > > If you wish to unsubscribe from this mailing, send mail to
> > >
[EMAIL PROTECTED] with a subject of:
> > >         unsubscribe castor-dev
> > >
> > >
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> >
[EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
>

Reply via email to