OpenJPA
  1. OpenJPA
  2. OPENJPA-1326

ReverseMappingTool and SchemaTool failing for Sybase

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.2.2, 1.3.0, 2.0.0-beta
    • Component/s: sql
    • Labels:
      None
    • Environment:
      Sybase
    • Patch Info:
      Patch Available

      Description

      invoking the org.apache.openjpa.jdbc.ant.ReverseMappingToolTask or the org.apache.openjpa.jdbc.ant.SchemaToolTask on a Sybase database gives the following stack trace

      java.sql.SQLException: S0022: Invalid column name 'TABLE_SCHEM'.
      at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(ErrorMessage.java:559)
      at com.sybase.jdbc3.tds.TdsResultSet.findColumn(TdsResultSet.java:624)
      at com.sybase.jdbc3.jdbc.SybResultSet.findColumn(SybResultSet.java:602)
      at com.sybase.jdbc3.jdbc.SybResultSet.getString(SybResultSet.java:349)
      at org.apache.openjpa.jdbc.sql.DBDictionary.newPrimaryKey(DBDictionary.java:3769)
      at org.apache.openjpa.jdbc.sql.DBDictionary.getPrimaryKeysFromGetPrimaryKeys(DBDictionary.java:3751)
      at org.apache.openjpa.jdbc.sql.DBDictionary.getPrimaryKeys(DBDictionary.java:3728)
      at org.apache.openjpa.jdbc.schema.SchemaGenerator.generatePrimaryKeys(SchemaGenerator.java:586)
      at org.apache.openjpa.jdbc.schema.SchemaGenerator.generatePrimaryKeys(SchemaGenerator.java:593)
      at org.apache.openjpa.jdbc.schema.SchemaGenerator.generatePrimaryKeys(SchemaGenerator.java:367)
      at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas(SchemaGenerator.java:274)
      at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas(SchemaGenerator.java:243)
      at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:1433)
      at org.apache.openjpa.jdbc.ant.SchemaToolTask.executeOn(SchemaToolTask.java:138)
      at org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:172)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      at org.apache.tools.ant.Task.perform(Task.java:364)
      at org.apache.tools.ant.Target.execute(Target.java:341)
      at org.apache.tools.ant.Target.performTasks(Target.java:369)
      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
      at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
      at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
      at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
      at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      at org.apache.tools.ant.Task.perform(Task.java:364)
      at org.apache.tools.ant.Target.execute(Target.java:341)
      at org.apache.tools.ant.Target.performTasks(Target.java:369)
      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
      at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:37)
      at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
      at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:382)
      at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:107)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      at org.apache.tools.ant.Task.perform(Task.java:364)
      at org.apache.tools.ant.Target.execute(Target.java:341)
      at org.apache.tools.ant.Target.performTasks(Target.java:369)
      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
      at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
      at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
      at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
      at org.apache.tools.ant.Main.runBuild(Main.java:687)
      at org.apache.tools.ant.Main.startAnt(Main.java:200)
      at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
      at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

      The data looks good from the driver, but when doing the getString calls, it has problems finding the columns that are aliased AS something else (ie, table_owner AS TABLE_SCHEM). A quick fix is to just use the original column names when getting the data from Sybase.

      pk.setSchemaName(pkMeta.getString("table_owner")); (search by column name) works, but
      pk.setSchemaName(pkMeta.getString("TABLE_SCHEM")); (search by column label) does not.

        Issue Links

          Activity

          Hide
          B.J. Reed added a comment -

          Forgot to mention, I have not tried this on trunk yet.

          Show
          B.J. Reed added a comment - Forgot to mention, I have not tried this on trunk yet.
          Hide
          Milosz Tylenda added a comment -

          Rick, have you experimented with Sybase driver properties like BE_AS_JDBC_COMPLIANT_ AS_POSSIBLE
          or GET_BY_NAME_USES_COLUMN_LABEL?

          Show
          Milosz Tylenda added a comment - Rick, have you experimented with Sybase driver properties like BE_AS_JDBC_COMPLIANT_ AS_POSSIBLE or GET_BY_NAME_USES_COLUMN_LABEL?
          Hide
          B.J. Reed added a comment -

          Thanks for the suggestions.

          We already had BE_AS_JDBC_COMPLIANT_ AS_POSSIBLE set. I tried GET_BY_NAME_USES_COLUMN_LABEL, but it still failed to find 'TABLE_SCHEM'

          --B.J.

          Show
          B.J. Reed added a comment - Thanks for the suggestions. We already had BE_AS_JDBC_COMPLIANT_ AS_POSSIBLE set. I tried GET_BY_NAME_USES_COLUMN_LABEL, but it still failed to find 'TABLE_SCHEM' --B.J.
          Hide
          Michael Dick added a comment -

          Thanks for the patch BJ. Committed in 1.2.x, 1.3.x, and trunk.

          Show
          Michael Dick added a comment - Thanks for the patch BJ. Committed in 1.2.x, 1.3.x, and trunk.
          Hide
          Milosz Tylenda added a comment -

          B.J., Rick, I am sorry, just noticed I confused your names in a previous comment.

          Show
          Milosz Tylenda added a comment - B.J., Rick, I am sorry, just noticed I confused your names in a previous comment.

            People

            • Assignee:
              B.J. Reed
              Reporter:
              B.J. Reed
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development