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

schema-delta generation (sqlAction=refresh) drops columns if they have an alternative typeName

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.0
    • Fix Version/s: 2.4.1
    • Component/s: jdbc
    • Labels:
      None

      Description

      I use Oracle with the following in my persistence.xml:

      <property name="openjpa.jdbc.Dictionary" value="(BitTypeName=CHAR(1),BooleanTypeName=CHAR(1),BooleanRepresentation=STRING_10)"/>
      

      It is all about the *TypeName. The BooleanRepresentation has no impact. I just added it to show the full use case.

      The problem is that during the MappingTool retain there is a Column#equalsColumn which only looks at the Type integers but not on any typeName representation in the DBDictionary.

      What now happens is that during openjpa:sql with sqlAction=build it perfectly creates a CHAR(1) for every boolean and Boolean field in my entity.
      But during a sqlAction=refresh it wrongly believes that the types it gets from the SchemaTool by parsing the real db (CHAR length1 java.sql.Types#CHAR=1) is not compatible to the type it sees in the MappingTool from parsing the Entity annotations + orm.xml (java.sql.Tpyes.BIT=-7).

      The result is that generated delta script wrongly drops the column and later adds it again with exactly the same definitions. And this happens every time...

        Activity

        Hide
        struberg Mark Struberg added a comment -

        A possible solution could be to add a 2nd Colum#equalsColumn which additionally takes the DBDictionary as parameter and if the default Types comparison doesn't return true then we take an additional look at the real db representation.

        Show
        struberg Mark Struberg added a comment - A possible solution could be to add a 2nd Colum#equalsColumn which additionally takes the DBDictionary as parameter and if the default Types comparison doesn't return true then we take an additional look at the real db representation.
        Hide
        struberg Mark Struberg added a comment -

        plz review

        Show
        struberg Mark Struberg added a comment - plz review
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1683992 from Mark Struberg in branch 'openjpa/trunk'
        [ https://svn.apache.org/r1683992 ]

        OPENJPA-2596 schema-delta generation (sqlAction=refresh) drops columns if they have an alternative typeName

        solved by additionally comparing the final column definition end to end

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1683992 from Mark Struberg in branch 'openjpa/trunk' [ https://svn.apache.org/r1683992 ] OPENJPA-2596 schema-delta generation (sqlAction=refresh) drops columns if they have an alternative typeName solved by additionally comparing the final column definition end to end

          People

          • Assignee:
            struberg Mark Struberg
            Reporter:
            struberg Mark Struberg
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development