0 Replies Latest reply on Nov 23, 2005 4:22 PM by Chris

    How to use CMR with generated primary keys

    Chris Newbie

      I two CMP beans which use database generated primary keys. (MySQL auto_increment) Tables A and B, with a one-to-many from A to B, cascade delete.

      The problem is that when I delete a record from A I get an error from MySQL which is of the form "Unknown column 'a' in 'where' clause".

      It seems the generated SQL is using the column name 'a' for the foreign key rather than 'aId' which it is.

      But then I can't use a <key-field> element in the jbosscmp-jdbc.xml to map to a column name because I need a field name. Generated keys don't get field names.

      Exposing the foreign key as a persistance field also doesnot seem to work.

      Does anyone have and example of how to do this.