0 Replies Latest reply on Sep 21, 2007 3:24 PM by Joshua Tharp

    Entity modeling with duel references

    Joshua Tharp Newbie

      I've got an application where the persistent data can be thought of as a graph (nodes and connectors). I'm trying to model this in Entity beans where each node is a bean and so is each connector. I have two issues: first, I'm getting confused on the type of relationship (and type of annotation to use) to model this, and two is how can I get cascading deletes to work in this model. So from a high-level each connector has two references to nodes, node1 and node2. Each node could have any number of connectors terminating on it.

      Looking at this problem from the whole objects' point of view I have a many-to-many relationship with each connector referring to exactly two nodes and each node having any number of connectors terminating on it. However, from an attribute point of view, I've got two many-to-one relationships in the connector object and a many-to-many relationship node (which I might be able to model as two one-to-many relationships). I do not need a node to know which connections terminate on it for the application's purposes, but have the understanding that it is necessary to make cascading deletes work correctly.

      Ideally, I would like to have cascading cleanup any connectors that terminate on a node that is removed.


      Help here would be greatly appreciated.