1 Reply Latest reply on Nov 11, 2003 1:09 PM by aloubyansky

    Composite pk containing a fk

    senthilcool

      If I have an entity using a composite primary key which includes a foreign key (as part of the pk) then I have to have cmp and cmr fields for the fk. Having this causes the container to do additional queries to confirm the existence of the related object (getRelatedEntityByFK() method in org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge). Is there a way to avaoid this? Can I have this work without creating the cmp fields for the fk?

        • 1. Re: Composite pk containing a fk
          aloubyansky

          If all foreign key fields mapped to pk fields, there is no way to avoid it.
          Because, in current implementation, it is supposed that CMP (and hence FK) fields could contain a value that does not match any related PK field. So, when a CMR is accessed we need to check whether the FK value is really valid.