Hi all,
New here and fairly new to hibernate so please bear with. have trawled docs and not found any suggestions for this so here goes;
I have an object, say "Transaction". It has one or more "Item"s. These items can be either "Treatment"s, "Course"s or "Product"s.
Each of those Items implements a common interface "SaleableItem". And my Transaction object has a List<SaleableItem> property.
I'm trying to map this into the DB with Hibernate annotations and am not really sure how to.
The DB tables I want to end up with are;
Transaction (ID, ...)
TransactionItem (ID, TransactionID, ItemID and ItemType)
Treatment (ID, ...)
Course(ID, ...)
Product(ID, ...)
Am ok with the standard mapping of Transactions, Treatments, Courses, etc.. but not sure how to map the List<SaleableItem> property of Transaction to the TransactionItem table such that when i retrieve a Transactions items I end up with a List of the relevant objects (Treatment, Course or Product).
Is this possible?? Any suggestions?? Or is this bad OO??
Many Thanks
|