How can I map a full table as a one-to-many set in a given object? Briefly I have a single root object (now not persistent but I can simply add a table with only one record to simulate it's persistence) and this root has many getters that should return collections of persistent objects. I would like to map them as like as a normal one-to-many collection but I have no foreign-key because all the records in the other table should be linked to this
object.
I would not add hibernate stuff into my "singleton" root object.
I've selected 2 solutions, but I'm blocked on both:
1) make the root persistent, load it from the session and work with this object as like any other hibernate object, but: I don't know how to map a whole table as a one-to-many set for this root.
2) create a new root object (non persistent) and populate it's collection with hibernate query, but: I need this collections to be lazy. How can I obtain a persistent hibernate collection object so that I can inject this object to into my root object?
Sorry for my poor english!
|