[Problem: equivalent with order-lineitem. If order is deleted, cmr-field of line-item is cleared which is part of line-item, so line-item gets useless]
Hi,
I have 3 domainObjects
Patient:
-id: String (PK)
-name: String
-password: String
Medicine:
-id: String (PK)
-name: String
Item:
-patient_id: String
-medicine_id: String
-quantity: Long
-sale_date: Long
primary key ItemPK = {patient_id,sale_date}
Now, I have 2 relations:
Patient-Item: 1 Patient points to n Items (patient_id)
Medicine-Item: 1 Medicine points to n Items (medicine_id)
As this patient_id and medicine_id are both cmp- and cmr-fields, I am setting them as cmp-field in EJBCreate(...) first, and afterwards as cmr-field in EJBPostCreate(...)
Pleaz note that I'm using cascade-delete from Patient to Item and from Medicine to Item
Everything works great, except when I try to remove a Patient who has Items:
-The patient is removed
-The patient_id of all the Items of this patient are set to 0, what
means that the primary key of these Items is changed and I can't do anything anymore with them.
I can't believe that this is a unique setup. Do you guys have any ideas or suggestions?
This type of mapping is not supported in JBoss. It is on the todo list, but as it is not spec compliant, it is not a high priority. In the mean time, I suggest that you change to a different primary key.