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 14:20:37 GMT
Hi Michael,

> > This would break many things. If
> > I call getObjectById() passing in Employee, and id value of 1 it wouldn't
> > know which subclass it should use if we have DB entries for a
> > FullTimeEmployee (1) and a PartTimeEmployee (1).
> I'm not sure what you mean by "getObjectById() passing in Employee".
> The object model specifies that class Employee is abstract. Thus, there  
> cannot exist persistent instances of Employee which are not instances of  
> Employee subclasses. This means that there are no object id instances 
> of class Employee. 

I mean that any user can call pm.getObjectById(id), and they could construct 
an "id" where the id is created as being for Employee with value "1". They 
would do this if they knew they had an instance of Employee (or subclass) 
that has an id of 1. The JDO impl then has to go off, realise that there are 
no implementations of Employee as such, and find the right subclass for this 
There should be *no way* of having a FullTimeEmployee with id "1" _and_ a 
PartTimeEmployee with id "1". They are 2 different objects and the id should 
be unique in an inheritance tree. With the situation in this test case 
currently they aren't, because there are 2 root tables (in this inheritance 
tree) and both are defined as having "IDENTITY" columns, so whenever anything 
is inserted into either a new id is allocated in that particular table 
(independent of the identity values allocated in the other table).

It would work fine if Employee had its own table since then there is 1 root 
table EMPLOYEE which would be the only table using IDENTITY. Sadly once you 
include subclass-table at the root level you get this problem. "autoassign" 
and "identity" both imply using the underlying datastore mechanisms and both 
will fall foul of this problem.


View raw message