• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Preserving Referential Integrity in Entity Beans

 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic