Discussions

EJB design: Using CMR with combined primary and foreign keys

  1. Using CMR with combined primary and foreign keys (1 messages)

    Is it possible to have a CMR field that maintains a relationship and also has a CMP field accessor. I'd like to use CMR on fields that are both a primary and foreign key.

    Thanks all.
  2. What you want to do is possible. You need two separate abstract fields, though: one for your CMP and one for your CMR:

    public abstract Long get/setFK();
    public abstract RelatedBean get/setRelatedBean();

    When you map the CMP EJB to the database, be sure to map the abstract FK field to the correct foreign key that maintains the relationship.