db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Spräner, Carsten <Carsten.Sprae...@viadee.de>
Subject Referencing an abstract class. The next turn...
Date Mon, 11 Oct 2004 05:33:24 GMT
Hallo to everybody.
I'm using OJB since release 0.7.4 and i still have a problem with mapping inheritance in version
1.0.1. I mailed the problem several times but it seems that it is still not solved correctly.
My problem is as follows:
Having a class Col which collects some items of class A. There is a subclass of A called B.
Meaning this UML-Diagram:
-------         * ---------
| Col  |  ----->|     A     |
-------           ----------
                     |     B      |
The repository mapps A in a table TABLE_A and B in an table TABLE_B. The inheritance is mapped
with the anonymous field feature of OJB. All IDs in all tables are unique. 
Problem 1: Storing an instance of Col is not possible. The containment of A is solved in a
field COL_ID inside the table TABLE_A and mapped to an anonymous filed colID inside the class
A. When storing the Object of class B ojb wants to access a field colID in B but can not find
the field. The field is in A. The stacktrace:
org.apache.ojb.broker.OJBRuntimeException: Incorrect or not found field reference name 'colId'
in descriptor org.apache.ojb.broker.metadata.CollectionDescriptor@199939[cascade_retrieve=true,cascade_store=object,cascade_delete=none,is_lazy=false,class_of_Items=class
db.A] for class-descriptor 'db.B'

at org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFieldDescriptors(Unknown

at org.apache.ojb.broker.core.PersistenceBrokerImpl.setFKField(Unknown Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.link(Unknown Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeAndLinkOneToMany(Unknown Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeCollections(Unknown Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown Source)

at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown Source)

Problem 2: Loading an instance of Col does not work correctly. The collection retrieved fom
OJB contains an instance of A AND an instance of Class B! This behavior is new against previos
versions of OJB. The instance of class B contains all Attributes of class A and class B. In
former releases it only contains the attributes of B.
This two problems makes it impossible to map inheritance on distinct tables for me. Maybe
there is a solution or a workaround. Please let me know. If you want i can give you a test
program with DDL, repository.xml and Testrunner to see the effect.
By the way: Mapping all classes of an inheritance tree to one table and using the ojbConcreteClass
feature works perfect. But thats not a solution for our customers.
Nevertheless OJB is a create tool and thank you all for delivering release 1.0.1. I like it
very much.
best regards....
Carsten Spräner

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

View raw message