I have a somewhat complicated tree node structure that i'm trying to use hibernate for.
I have 2 objects, a TreeNode and a TreeNodeGroup, and a table for each. TreeNodes are pretty much what you expect, however, their children are not TreeNodes but TreeNodeGroups. Each TreeNode has 0..M TreeNodeGroups, and each TreeNodeGroup has 0..M TreeNodes.
The reason for doing this is that I want to group TreeNodes together in a group, and then use that group as children for any TreeNode.
In order to keep track of this relationship, I have 2 relational tables: A) for linking TreeNode -> TreeNodeGroups, and B) for linking TreeNodeGroup -> TreeNodes.
The entities are related to each other, but in two ways! The parent node -> child groups, and parent group -> child nodes.
My question is, how do I do the many-to-many associations in the hbm.xml?
I don't need to go backwards from the child -> parent, so I tried leaving out the inverse attribute, but I get JDBC commit errors on a get, which means that just by retrieving an object, Hibernate thinks it's been modified, so it tries to save it back to the DB and breaks some DB constraint, which throws an exception.
|