Cl�vis Wichoski wrote:
After several days trying to use Multiple Joined Tables with XDoclet, I can do this work, but there are more things with Multiple Joined Table and XDoclet that I need to know how to do.
first this are sample classes for better understanding:
/** * @ojb.class table="PERSON" * determine-extents="false" **/ public class Person { /** * @ojb.field column="OID" * length="8" * primarykey="true" **/ public String oid; /** * @ojb.field column="VERSION" * locking="true" **/ public int version;
/** * @ojb.field column="SHORTCUT" * length="20" **/ String shortcut;
/** * @ojb.field column="NAME" * length="40" **/ String name;
/** * @ojb.collection element-class-ref="Address" * foreignkey="myPersonOid" * auto-retrieve="true" * auto-update="object" * auto-delete="object" **/ java.util.Vector myAddress; }
/** * @ojb.class table="COMPANY" * include-inherited="false" * @ojb.field name="oid" * column="oid" * jdbc-type="VARCHAR" * length="8" * primarykey="true" * @ojb.reference class-ref="Person" * foreignkey="oid" * auto-retrieve="true" * auto-update="object" * auto-delete="object" **/ public class Company extends Person {
/**
* @ojb.field column="FOUNDATION_DATE"
* conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimestampFieldConversion"
* jdbc-type="TIMESTAMP" **/ java.util.Date foundationDate; }
/** * @ojb.class table="NATURALPERSON" * include-inherited="false" * @ojb.field name="oid" * column="oid" * jdbc-type="VARCHAR" * length="8" * primarykey="true" * @ojb.reference class-ref="Person" * foreignkey="oid" * auto-retrieve="true" * auto-update="object" * auto-delete="object" **/ public class NaturalPerson extends Person { /** * @ojb.field column="MOTHER_NAME" * length="40" **/ String motherName;
/** * @ojb.field column="FATHER_NAME" * length="40" **/ String fatherName; }
/** * @ojb.class table="ADDRESS" * @ojb.field name="myPersonOid" * column="MY_PERSON" * jdbc-type="VARCHAR" * length="8" * @ojb.field name="myCityOid" * column="MY_CITY" * jdbc-type="VARCHAR" * length="8" **/ public class Address {
/** * @ojb.field column="OID" * length="8" * primarykey="true" **/ public String oid;
/** * @ojb.field column="VERSION" * locking="true" **/ public int version;
/** * @ojb.field column="STREET" * length="40" **/ String street; /** * @ojb.reference foreignkey="myCityOid" **/ City myCity; }
/** * @ojb.class table="CITY" **/ public class City { /** * @ojb.field column="OID" * length="8" * primarykey="true" **/ public String oid;
/** * @ojb.field column="VERSION" * locking="true" **/ public int version;
/** * @ojb.field column="NAME" * length="40" **/ String name; }
/** * @ojb.class table="USER" * @ojb.field name="myCompanyOid" * column="MY_COMPANY" * jdbc-type="VARCHAR" * length="8" * @ojb.field name="myNaturalPersonOid" * column="MY_NATURAL_PERSON" * jdbc-type="VARCHAR" * length="8" **/ public class User { /** * @ojb.field column="OID" * length="8" * primarykey="true" **/ public String oid;
/** * @ojb.field column="VERSION" * locking="true" **/ public int version;
/** * @ojb.field column="LOGIN" * length="15" **/ public String login;
/** * @ojb.field column="PASSWORD" * length="15" **/ public String password;
/** * @ojb.reference foreignkey="myCompanyOid" **/ Person myCompany;
/** * @ojb.reference foreignkey="myNaturalPersonOid" **/ Person myNaturalPerson; }
Issues:
1) For this works after repository_user.xml is generated, I manually remove the anonymous attribute of field oid from classes Company and NaturalPerson, then how do this, without override oid in subclasses? (If don't remove I get a java.lang.NullPointerException because oid is a primary key)
Rather than using include-inherited="false" for Company, you should use
@ojb.modify-inherited ignore="true" name="[feature name]"
in Company's class javadoc comment for the fields/references/collections that you do not wish to inherit. This way, you don't have to redeclare the primary key field. And you'll get the references and collections from the super classes.
Tom
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
