Hello, Help me please, I use castor for database import-export. I read the data from DB1 (line from A and all lines from B with B.IdA=A.IdA) and then I store it in DB2.
All works well when I realise pass by : DB1 -> JDO1 -> JDO2 -> DB2. But when I pass by : DB1 -> JDO1 -marcsalling-> (XML) -unmarcsalling-> JDO2 -> DB2 I lost the relations A-B. In another words the values of B.IdA are NULL !!! I understand what the problem in mapping for XML. Can somebody write me mapping file for this sample (A-B)??? I try to generate the castor classes for schema of existing database. I don't understand how I must to mark the relation with ForeignKey. IF ANYBODY HAVE AN EXAMPLE WITCH WORK SEND ME PLEASE. ------------------------------------------- for example: I have 2 tables: with realationship A -(1)-----(0..m)-B ====== table A : -------- IdA (PK) ValueA ====== ====== table B : --------- IdB (PK) IdA (FK) ValueB ====== ---------------------------------------------------------- XSD file for Castor Class Genetrator : Is it correct ? ---------------------------------------------------------- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="A" id="IdA"> <xs:complexType> <xs:sequence> <xs:element ref="B" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="ValueA" type="xs:string"/> </xs:sequence> <xs:attribute name="IdA" type="xs:integer" use="required"/> </xs:complexType> </xs:element> <xs:element name="B" id="pkb"> <xs:complexType> <xs:sequence> <xs:element ref="A" minOccurs="1" maxOccurs="1"/> <xs:element name="valueb" type="xs:string"/> </xs:sequence> <xs:attribute name="IdB" type="xs:integer" use="required"/> <xs:attribute name="IdA" type="xs:integer" use="required"/> </xs:complexType> </xs:element> </xs:schema> -------------------------- Is the MAPPING file... is it correct ? ---------------------------- <mapping> <class name="A" identity="IdA" key-generator="MAX"> <map-to table="A" xml="A"/> <field name="IdA" type="java.lang.Integer" get-method="getIdA" set-method="setIdA"> <sql name="pka" type="integer"/> </field> <field name="ValueA" type="string" get-method="getValueA" set-method="setValueA"> <sql name="getValueA" type="char"/> </field> <!-- relation: A-B --> <field name="B" type="B" collection="arraylist" get-method="getBAsReference" set-method="setBAsReference"> <sql many-key="IdA"/> </field> </class> <class name="B" identity="IdB" key-generator="MAX" depends="A" > <!-- I MUST TO USE HERE : depends="A" ??? IF YES WHAT I HAVE TO DO IF THE TABLE B WILL HAVE MORE THAN ONE FOREIHN KEY ???--> <map-to table="B" xml="B"/> <field name="IdB" type="java.lang.Integer" get-method="getIdB" set-method="setIdB"> <sql name="IdB" type="integer"/> </field> <!-- HAVE I TO INCLUDE THIS FIELD HERE OR NOT ??? --> <field name="IdA" type="java.lang.Integer" get-method="getIdA" set-method="setIdA"> <sql name="IdA" type="integer"/> </field> <field name="valueB" type="string" get-method="getValueB" set-method="setValueB"> <sql name="getValueB" type="char"/> </field> <!-- relation: A-B --> <field name="A" type="A" required="true"> <sql name="IdA"/> </field> </class> </mapping> If you have an example wich Vladimir ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
