Hi,

I think I have the same problem as Thomas Louis in his post on 04/15.
Recall:

>I get the following Exception, when using lazy loading with an arraylist.
If
>I disable lazy loading it works.
>Here is the error-message:
>org.exolab.castor.jdo.DataObjectAccessException: Type conversion error:
>could not set value of FieldMolder of
>com.gastroeasy.xml.Artikel.setkonditionList(com.gastroeasy.xml.Kondition
>konditionList)


I stepped through the Castor code and I see the following problem (among others):

- During initialization:
  - FieldMolder gathers setter and getter methods for all fields
  - in the case of a lazy loaded collection:
      see if a setMyObjects() exists with the argument type as specified in
mapping.xml, i.e.
      ArrayList (wrong!)
      add this to the ReflectService object of the field
- During a query:
  - if collection is not lazy
    - call the addMyObject() method with the loaded object as parameter
  - if it is lazy
    - build a RelationCollection with references to the stored objects
    - call the set method with that collection (ouch! it's not an ArrayList)

This last call fails because it expects an ArrayList, for example.
Solution:

- as a user: if you have lazy relationships, change the collection type to
"collection" in your mapping.xml file, and provide a setMyChilds(Collection)
method
- for Castor developers (sorry I can't contribute code at this time):
  - the FieldMolder should make sure there's setMyObjects(Collection) method
when loading is lazy
  - please change the error text from
    "myPkg.myCls: no method to set value for field: myPkg.myCls in class:
ClassMolder myPkg.myCls"
    to something like
    myPkg.myCls: method "void setChilds(java.util.Collection)" not found.

Interestingly enough, I couldn't find any references on that issue on the
web nor in the mailing list. 
I was using yesterday's CVS version.
I also couldn't find any word on lazy loading within the castor jdo docs. Is
it still so experimental?


Clemens
 

Reply via email to