Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-427

PostgresDictionary should set "63" as "maxAutoAssignNameLength".

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 1.0.0, 1.1.0
    • 1.1.0
    • sql
    • None
    • PostgreSQL 8.1.

    Description

      PostgresDictionary should set "63" (or something correct) as "maxAutoAssignNameLength", in order to let DBDictionary#getGeneratedKeySequenceName() generate correct names for IDENTITY sequences.

      OpenJPA trims IDENTITY sequence names longer than 32 characters, while PostgreSQL uses longer names for BIGSERIAL sequences. So, persisting entities with @Id column with GenerationType.IDENTITY often results in a database error such as :
      org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR: relation "x_school_membershi_entityid_seq" does not exist

      {prepstmnt 2398193 SELECT CURRVAL(X_SCHOOL_TRANSFER_entityId_SEQ')}

      [code=0, state=42P01]

      The followings are the examples. "OK"s are the sequence names which PostgreSQL uses. "NG"s are those which OpenJPA attempts to use.

      Ex.1 -
      Table : X_SCHOOL_TRANSFER_EVENT
      BIGSERIAL Column : ENTITYID
      OK : X_SCHOOL_TRANSFER_EVENT_ENTITY_ID_SEQ
      NG : 'X_SCHOOL_TRANSFER__ENTITYID_SEQ

      Ex.2 -
      Table : X_SCHOOL_MEMBERSHIP
      BIGSERIAL Column : ENTITYID
      OK : X_SCHOOL_MEMBERSHIP_ENTITYID_SEQ
      NG : X_SCHOOL_MEMBERSHI_ENTITYID_SEQ

      Attachments

        1. mychanges.patch
          0.6 kB
          Ryosuke Iwata

        Activity

          People

            Unassigned Unassigned
            isana Ryosuke Iwata
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: