Hibernate version:2.1.4
Hi there,
Here is a technical question, in the database I have this table.
CREATE TABLE commitment_item (
CommitmentId id REFERENCES commitment ON DELETE CASCADE,
Ord ord,
ObjId id NULL, ObjType type CHECK (ObjType in ('CO', 'Item')) NULL,
PRIMARY KEY (CommitmentId, Ord)
);
And because the object can mapped to "CO" or "Item" in hibernate according to the "ObjType" column using "ObjId".
It is OK to use <descriminator-value> to make the CoCommitment object and ItemCommitment object extends from Commitment.
But what I want is: Only a Commitment object in hibernate, but you can use some methods like setXXX(), then when update, hibernate will automatically update the "ObjId" "ObjType" according to the received value.
When receiving a CO, the objType will be 'CO', when receiving an Item, the objType wil be 'Item'...
Is there any way to accomplish this in Hibernate? Thank you very much in advance.
|