Discussions

EJB programming & troubleshooting: Doubt in CMP-RELationship

  1. Doubt in CMP-RELationship (2 messages)

    error java.rmi.RemoteException: EJB Exception:; nested exception is:
            javax.ejb.EJBException: When a cmp-field and a cmr-field (relationship)
    are mapped to the same column, the setXXX method for the cmp-field may not be called.
    The cmp-field is read-only.

    How to know to which column in the database these two fields are mapped........

    please tell me what could be wrong.....

    VERY URGENT....


    Threaded Messages (2)

  2. Doubt in CMP-RELationship[ Go to top ]

    Hi,
    for any CMR field, u should have correspondinig setXXXEntity method.
    (eg)
    childEntityObject.setParentEntityObject(parentEntityObject);

    Regular setXXX methods are only for cmp fields.
  3. Doubt in CMP-RELationship[ Go to top ]

    Hi,

    I think you might be having a similar problem that i had.
    If you are using EJB2.0 you can specify abstract gets and sets for all you CMP fields. You can also do the same for relationships.

    e.g.
    public abstract UserGroup getUserGroup();
    public abstract void setUserGroup(com.theinagency.user.ejb.UserGroup userGroup);

    In my case i wanted to use an email address to map a user to a user group table for access control.

    So i though i will just create the relationship in the ejb-jar.xml mapping the email column to the primary key in the usergroup ejb. Because email was already a CMP field (which i wanted to keep) the server gave me a similar error.

    I ended up creating another column just to be used a key which is identical to the email column. This isn't great but it works ok. Might have been simpler to remove the CMP mapping for the email field but i wanted a finder method on the email column.

    Hope this helps.

    Owen