You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Clóvis Wichoski <cl...@uol.com.br> on 2004/08/18 15:21:56 UTC

How to ignore anonymous fields from super using XDoclet


Hi,

I having a trouble using Multiple Joined Tables with XDoclet, If i had a reference in superclass 
the anonymous field for this reference is replicated, in generated subclass descriptor. 

first this are sample classes for better understanding:

---------START OF CLASS DEFINITIONS---------------------

/**
* @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.class table="PRODUCT"
*            determine-extents="false"
* @ojb.field name="myManufacturerOid"
*            column="MY_MANUFACTURER"
*            jdbc-type="VARCHAR"
*            length="8"
**/
public class Product {
    /**
    * @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.reference foreignkey="myManufacturerOid"
    **/
    Person myManufacturer;
}

/**
 * @ojb.class table="MOTORCYCLE"
 * @ojb.modify-inherited ignore="true" name="version"
 * @ojb.modify-inherited ignore="true" name="name"
 * @ojb.reference class-ref="Product"
 *                foreignkey="oid"
 *                auto-retrieve="true"
 *                auto-update="object"
 *                auto-delete="object"
 **/
public class Motorcycle extends Product {

    /**
    * @ojb.field column="CHASSIS" 
    *            length="20"
    **/
    String chassis;
}

---------END OF CLASS DEFINITIONS---------------------

Now the trouble with XDoclet are:

If I attempt to query any Motorcycle, I get a Unknown column name: MY_MANUFACTURER from Database, because 
the anonymous field is replicated on Motorcycle descriptor, if include in Motorcycle class:

* @ojb.modify-inherited ignore="true" name="myManufacturer"

The reference declaration goes out from motorcycle descriptor, but anonymous field no, then if include:

* @ojb.modify-inherited ignore="true" name="myManufacturerOid"

I get the follow exception when generating descriptors with ant:

[ojbdoclet] SEVERE: The reference myManufacturer in the class Motorcycle uses the field myManufacturerOid as foreignkey although this field is ignored in this class

But I need to maintain reference if I need to Query all Motorcycle from a specific Manufacturer.

I can do this work, only, removing generated anonymous field from descriptor, but this is a hard work, 
since I had here, more than 150 classes ;), because of this I use XDoclet.

how I can do this mapping using XDoclet?

Best regards

Clóvis



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org