Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Preserving Referential Integrity in Entity Beans

 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i was leafing through the Ed Roman book when i encountered a few concepts which i can not sink in, any help in this regard shall be appreicated

Situation: 1:N Relationship [Company:Employee]
Original Relationship: Company A - Employee A
Company A - Employee B
Company B - Employee C
Company B - Employee D

Operation : CompanyA.setEmployees(CompanyB.getEmployees());

New Relationship: NULL - Employee A
NULL - Employee B
Company A - Employee C
Company A - Employee D
Company B - Empty Collection

My understanding : it is perfectly understandable to make CompanyB an empty collection because since its 1:N an employee cannot belong to two companies they have to be removed from previous companies. So far so good, but why do employee A and B have to be made into null(no companies at all). what is wrong with Company A having Employee A,B,C,D after the operation.
i am sure the book is correct but i need the rationale behind it.

Thanks in Advance,
Rahul
 
Aru San
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,

Please note that you have replaced the existing set of employee with company B's employees. that is why Employee A and B dont belong to any company after the call.

Regards
Aruna
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,

i kinda figured that ....after banging my head against the wall

The difference is if i perform an add() operation of collections it adds otherwise it replcaces modifying the existing relationships..

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic