Uploaded image for project: 'Rave'
  1. Rave
  2. RAVE-680

Rave is not generating Foreign Keys with default JPA implementation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.13
    • None
    • None

    Description

      Rave is not generating any foreign keys as part of the default OpenJPA implementation.

      Steps:
      1) Start up Rave using the default H2 database
      2) Log into H2 web console http://localhost:11111
      3) Execute: DELETE FROM WIDGET; COMMIT;

      Step 3 should throw a foreign key constraint error because widget_id is referenced in other tables, but it allows the deletes. I also verified in an Oracle installation that there are zero foreign key constraints in the schema. There are primary, check, and unique constraints but no foreign key constraints.

      It appears that the default OpenJPA behavior[1] is to NOT create foreign keys (ugh), but this can be modified with a property:

      <property name="openjpa.jdbc.MappingDefaults" value="ForeignKeyDeleteAction=restrict, JoinForeignKeyDeleteAction=restrict"/>

      [1] http://openjpa.apache.org/faq.html#FAQ-WhyOpenJPAisnotcreatingforeignkeyconstraintsonthedatabasetables%253F

      Attachments

        Activity

          People

            carlucci Tony Carlucci
            carlucci Tony Carlucci
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: