Inheritiance Mapping and Subclasses
zbNov 6 2008 — edited Nov 6 2008Toplink 10.1.3.3.0
WAS 6.1
Java 1.4
Oracle 10
Assume the following Database Structure.
Table: REQ
PK: id
column: empId
column: indicator
Table TK_REQ
PK: id
column: midweek
-----------------------------
Assume the following Java Objects
//maps to REQ table
public class Req {
private id;
private indicator;
private empId;
}
//maps to TK_REQ table
public class TkReq extends Req {
private midweek;
}
Assume we use standard inheritance mapping (objects are fully mapped) in Toplink using Req.indicator as our inheritance indicator. When we access the TkReq object, Toplink will read both tables to bring back a full object.
Now the question: Assume I create a third object called proxy.
public class Proxy extends TkReq {
List<Action> vals;
}
The proxy class is mapped onto the TK_REQ table ALSO!! The reason we do this is that the Proxy is an class that also holds the Action list and we want toplink to manage both togeter.
How do i map this Proxy class in Toplink such that it brings back a FULL object including all the parent (TkReq) and parent/parent (Req) data also?
Am I allowed to map two separate classes onto the same table? Will this cause synchronization errors as we are doing Toplink invalidation via clustering since one object might update and not notify the other.
Based on my last statement (synchronization), we tried to delegate to the TkReq object instead of inherit. The obvious problem is that Proxy needs to be mapped to a table to be a Class descriptor. Therefore, we used TK_REQ and only mapped the PK AND mapped the delegation as 1:1. However, this throws a workbench error that the table reference is invalid on the delegated object. This would appear to be a bug in Toplink.
Thanks!