Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB design .. which relation :confused:

meka toka
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following situation
In the underlying datastore it should look as below
-> A is associated with many instances of B
-> B is associated with many instances of A
-> A doesnt have a primary key, it is reached in the database through its parent C
C has n instances of A and they have a relation 1:N
-> D has a 1:N relation with B, however B has a primary key. So B can be reached through D or by doing a direct look up on B.
In the presentation layer i wanna show the data as below
-> There are 2 trees viz.,
(a) one which is based on A,C,B
(b) another based on D,B,A
-> Now the first tree would have C on first level, C would have 'n' instances of A, which in turn 'uses' B
-> In the second tree D is on first level, it would have 'n' instances of B, and B in turn would have 'n' instances of A
-> About the cascade deltes and all,
When C is deleted, A is cascade deleted
When D is deleted, B is cascade deleted
-> When A is deleted B is not deleted and vice-versa but we want to update the lists of A in B and B in A.

For the above situation ... what kind of relation would be best suited between A and B.
I am thinking of implementing 'a fake' M:N bidirection between A and B by creating a third bean called AB which represents the relation M:N as two parts
AB to A as N:1 &
AB to B as N:1
But still am looking for some suggestions from any of the experienced people
Meka Toka
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic