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?
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.