Greetings,
I have a fairly complex mapping problem. I have one solution for it but it is not as elegant as I would like. Hopefully someone on here has run into a similar problem and found a cleaner solution.
Having said that, I have four tables that are linked together with foreign keys, etc.
Parent
-------------
id:long
(other junk)
MetaFields
----------------
id:long
parentClass:String
fieldName:String
MetaOptions
----------------
id:long
metafieldsID:long
value:String
MetaValues
----------------
id:long
parentid:long
metafieldsid:long
metaoptionsid:long
freeformvalue:String
Hopefully that is clear. Basically Parent is the main object that I want to load. The other objects should get loaded automatically. MetaFields is a direct child of parent joined by parent's actual class name. MetaOptions is a child of MetaFields with a simple foreign key. The hard table is the MetaValues table. It is linked to Parent, MetaFields and MetaOptions.
The initial solution I have come up with is to link Parent --> MetaFields --> MetaOptions as normal and then load MetaValues as a direct child of Parent. Then just use some coding in the Parent object to link it into MetaFields. I would rather having Hibernate Link the MetaValues in but I am not sure if it is possible.
I look forward to any suggestions anyone may have (other than changing the table structures which is not an option).
Thanks,
Marcus[b][/b][b][/b]
|