Hi!
How could I configure OJB to process such scheme:
I have base class A and at least one its subclass B. Each class uses
different DB tables, joined to each other. In following examples I have
TABLE_B references to TABLE_A by foreign key PARENT_ID.
There is also third class, lets say 'ObjList' having 1:n relation to
base class A.
Java code looks like this:
package objs;
/* @ojb.class table="TABLE_A"
* @ojb.extent class-ref="objs.B"
* @ojb.field name="listId"
* column="list_id"
* jdbc-type="INTEGER"
*/
class A {
/* @ojb.field column="id"
* jdbc-type="INTEGER"
* primarykey="true"
*/
int id;
/* @ojb.field column="field1"
* jdbc-type="INTEGER"
*/
int field1;
/* @ojb.field column="field2"
* jdbc-type="INTEGER"
*/
int field2;
/* @ojb.reference foreignkey="listId"
* auto-retrieve="true"
* auto-update="link"
* auto-delete="link"
*/
ObjsList list;
}
/* @ojb.class table="TABLE_B"
* include-inherited="false"
* @ojb.field name="id"
* jdbc-type="INTEGER"
* column="id"
* primarykey="true"
* @ojb.field name="parentId"
* column="parent_id"
* jdbc-type="INTEGER"
* access="anonymous"
* @ojb.reference class-ref="objs.A"
* auto-retrieve="true"
* auto-update="object"
* auto-delete="object"
* foreignkey="parentId"
*/
class B extends A {
/* @ojb.field column="field3"
* jdbc-type="INTEGER" */
int field3;
}
class ObjsList {
... various fields ...
/* @ojb.collection
* element-class-ref="objs.A"
* foreignkey="listId"
* auto-retreive="true"
* auto-update="link"
* audo-delete="none"
* proxy="true"
*/
List<A> objs;
}
That's scheme gives me error during XDoclet stage:
"The collection entries in class ojbs.ObjsList specifies a foreignkey
listId that is not a persistent field in the element class (or its
subclass) objs.B"
If I include declaration of listId field to class "B" (via
include-inherited="true" or place separate ojb.field to class B, then
OJB suppose TABLE_B have LIST_ID column, though it doesn't.
The following SQL generated when method getObjs() invoked on ObjsList
instance.
SELECT count(*) FROM TABLE_B A0 INNER JOIN
TABLE_A A1 ON A0.parent_id=A1.id WHERE A0.list_id = ?
Why OJB forces class B have listId?
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]