db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Jefferson <a...@jpox.org>
Subject Re: Inheritance test schema 2 : "subclass-table" and "identity" strategy
Date Wed, 28 Sep 2005 15:29:10 GMT
Hi Michael,

> My understanding is that your scenario applies to datastore identity.
> Applications can only construct objectid instances in case of
> application identity. So, how would an application get an Employee
> objectid instance?

I was quoting one example of where things break in this situation. I can 
certainly create a datastore identity (of the JPOX OID type, since datastore 
id is JDO impl specific) with Employee as the class and 1 as the value. The 
fact remains that you're creating, by the specification of IDENTITY type, and 
"identity" strategy, objects which have the same "key" in their id in the 
same inheritance tree, and so issues will result. This was one example.

> Do you agree that in case of datastore identity getObjectById can be
> resolved for FullTimeEmployee/PartTimeEmployee objectid instances, even
> if there are rows in tables fulltimeemployees and parttimeemployees
> having the same pk values?

I agree that *if* I have a full complete id with correct class, then I can 
find the row, since the class has been specified. What I'm saying is that 
there situations where you only have the "id" and not the class. The 
pm.getObjectById() is one example.

Let's have another example :-)
I've got a class (e.g Project) with a collection field and I'm storing objects 
of type Employee (declared in the metadata). I have a join table for storing 
the linkage between owner and element. I need to find the elements of the 
collection when retrieving the owner object. Now the only thing in the join 
table of use is a column which has the "id" of the Employee object that is 
contained in this collection. It doesn't say, "this is a FullTimeEmployee 
with id 1". It just says "its an Employee" (from the collection MetaData) and 
the FK column says "1" is the id of the object. So which element table do I 
join to ? Do I go to FULLTIMEEMPLOYEE ? Do I go to PARTTIMEEMPLOYEE ? How do 
i decide ?

Having duplicate id "values" in an inheritance tree representing different 
objects is a "bad thing".


View raw message