Title: My sucessfull experience with castor

Just three months ago I started playing with castor. Really incredible. But few bugs, maybe becouse I don't know who to do, maybe castor have few errors ;-)

Today I can say, that castor is an incredible tool, but it can be confused because of a lack of documentation.

My guidelines to star a project with castor, as a java Api Binding tool, and as an O/R tool is this.


1.- Get/write and schema, and use Castor Source Generator. Only with this you can read, and write xml files, based on the objects generated with castor. (Take care of methods marsahllunmarshall inside generated objects.)

2.- Copy this schema and ADD the identities and the references to another objects to the new one. Then generate the new classes WITHOUT class descriptors. SO you have the class descriptors without ID's and references, and the objects with ID's and reference.

3.- Make the mapping.xml file. It's really easy, you only have to take care of <field> and <sql> element.

4.- Prepare some test cases and start working with castor.


All is perfect, but there is only one problem in point 2, Castor Source Generator don't work with bidirectional realtions. I don't know why. I think that it is very easy to do it.


I descrive it in one past email.

I think it is only need to change org.exolab.castor.builder.CollectionInfoJ2 and this changes

1)pass JClass to the createAddInsertMethod

Line 115, 123 --> createAddMethod(method, jClass); createAddInsertMethod(method, jClass);

2) add the code to create the bidirectional relationship (maybe you have to take care that jClass is not a class of a primitive type, becouse if it's, is imposible to set a bidirectional relation, but this never happen to me)

some point near line 249 and 281 -->jsc.add(getContentType().createToJavaObjectCode(getContentName())+".set"+ jClass.getName(true) +"(this);");


Hope this help to someone.


Regards, Enrique.

PS: Pardon for my english

Reply via email to