Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Frits Walraven
  • Piet Souris

CMR Problem

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I wanted to understand better how to implement CMR ( relationships in EJB ) . For a particular example of two EJBs , Bank and Branches . These two EJB have a one to many uni-directional relationship .
Bank ejb has a collection CMR field for branches and branches has a bank CMR field .
According to the Head First EJB book , fields which actually represent the relationship ( the actual foreign key field ) , must not be represented as a CMP field .

For the Branches entity , my primary key is bank code + branch code . Also bank code is a foreign key to banks table .

Now for the rules of Primary key in entity beans , all fields in Primary key , must be a CMP .
So is it correct here to represent branch code as a CMP field and ( in branches EJB ) and also have a CMR field for Banks .Is there a basic problem with this design ? .

Because for some reason , I am not able to get this relation working as it is supposed to work .
( Specially the set methods do not work as explained in the EJB spec . If I want to set all branches of a bank to another bank , the expected result is not achieved after the set operation ) . I used Websphere 5.1 for this scenario .

Please comment .

Author & Gold Digger
Posts: 7617
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the EJB forum. Please continue discussing this topic there. Thank you
I am a man of mystery. Mostly because of this tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic