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 "Anthony E. Carlos" <an...@digitalphenom.com> on 2004/09/02 15:54:40 UTC
Mapping inheritance hierarchies
Hello all,
Here's a question about mapping inheritance hierarchies. Yes, I've read
http://db.apache.org/ojb/docu/guides/advanced-
technique.html#Mapping+Classes+on+Multiple+Joined+Tables. Let's say I
have a base class A, and classes B and C which both extend A. I am
mapping classes on multiple joined tables, and have set auto-update to
true. OJB is working great when I insert/update B or C classes and is
properly populating table A plus B or C. However, if I want to save a C
class with the same primary key as an existing B class (effectively
giving an instance of B some qualities of C), OJB is trying to insert a
record into A and I get a unique key constraint violation since the
primary key already exists. I was wondering why OJB was trying to do an
insert even though I've already specified a primary key.
I tried the hint in
http://db.apache.org/ojb/docu/tutorials/pb-
tutorial.html#Updating+Persistent+Objects to force an update (which
didn't change anything):
// alternative, more performant
// broker.store(result, ObjectModificationDefaultImpl.UPDATE);
This leads me to believe that I may have a wrong assumption in design.
Perhaps B and C cannot share the same A? How would you map it? Is there
a better pattern to follow?
Thanks,
-Anthony Carlos
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org