OpenJPA
  1. OpenJPA
  2. OPENJPA-2045

NAME is a valid column name for H2 databases.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.0, 2.2.0
    • Fix Version/s: 2.2.0
    • Component/s: jdbc
    • Labels:
      None

      Description

      This issue was originally reported on the users mailing list : http://openjpa.208410.n2.nabble.com/GenerationType-TABLE-question-column-name-suffixed-with-0-td6729676.html.

      The H2 DBDictionary is picking up the default list of invalid column names from openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/sql-keywords.rsrc, which includes "NAME". As a result we're trying to fix the column so that it contains a valid identifier, and end up with the wrong value.

      Users can work around the problem by delimiting columns in their annotations or xml mapping files, for example :
      @javax.persistence.TableGenerator(
      name = "fred",
      table = "jpa_sequence",
      pkColumnName = "\"name\"",
      valueColumnName = "last_value",
      pkColumnValue = "fred",
      allocationSize = 500)

      To fix the problem we need to either remove NAME from the default list, or manually remove it in the H2 Dictionary. Some additional investigation may be needed to determine whether this is a problem for other databases too.

      1. OPENJPA-2045.patch
        8 kB
        Jacob Nowosatka

        Activity

        Michael Dick created issue -
        Hide
        Jacob Nowosatka added a comment -

        I did some research and it seems that for only a few databases is "NAME" as a reserved keyword.
        Access
        FoxPro
        Informix
        Pointbase

        Thus, I have opted to remove "NAME" from the list of common reserved words and made it specific to each database listed above. The attached patch does just this.

        Show
        Jacob Nowosatka added a comment - I did some research and it seems that for only a few databases is "NAME" as a reserved keyword. Access FoxPro Informix Pointbase Thus, I have opted to remove "NAME" from the list of common reserved words and made it specific to each database listed above. The attached patch does just this.
        Jacob Nowosatka made changes -
        Field Original Value New Value
        Attachment OPENJPA-2045.patch [ 12494523 ]
        Michael Dick made changes -
        Assignee Jacob Nowosatka [ jtnowosatka ]
        Hide
        Michael Dick added a comment -

        Thanks for the patch. This should be included the next nightly snapshot.

        Show
        Michael Dick added a comment - Thanks for the patch. This should be included the next nightly snapshot.
        Michael Dick made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 2.2.0 [ 12315910 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        13d 23h 26m 1 Michael Dick 15/Sep/11 13:29

          People

          • Assignee:
            Jacob Nowosatka
            Reporter:
            Michael Dick
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development