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 .