6 Replies Latest reply on Jan 28, 2003 10:41 AM by Gianluca

    Foreign key fields mapped to primary key fields in JBoss-3.2

    Alexey Loubyansky Master

      It's possible to map foreign key fields in one-to-many and one-to-one
      relationships to the primary key fields. All is needed is to assign the same
      names to the corresponding foreign and primary key fields.

      Relationships are assigned between ejbCreate and ejbPostCreate. This
      means that relationships are accessible in ejbPostCreate and not in ejbCreate.
      Relationships are established and removed only with creation and
      removal of entities. Modifications with abstract CMR accessors are not
      allowed as they change primary key values.

      If ONE side doesn't exist CMR on the MANY side will return null value.
      If MANY side doesn't exist CMR on the ONE side will return empty collection.

      If cascade-delete is specified then removal of the ONE side will
      remove the related MANY side. In this case, ONE side is removed first
      breaking the relationship, i.e. CMR field on the MANY side in ejbRemove will return null.