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

Entity attribute using keyword as name failed on Mapping tool even name is quoted using @Column(name="\"GROUP\"")

Agile BoardAttach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.2, 2.3.0, 2.4.0
    • Fix Version/s: None
    • Component/s: jpa
    • Labels:
      None

      Description

      Have a entity using keyword as attribute name but overridden with @Column to quote the keyword as in:

      @Entity
      public class KeyWord { .....
      @Column(name="\"GROUP\"")
      private String group;
      }

      The first time createEmf and createEm create the table with proper column name (i.e. GROUP). When the second time (table already existed) the same test case is run, the following exception is thrown.

      1310 TRACE [main] openjpa.jdbc.SQL - <t 706835911, conn 352584430> executing stmnt 1628232398 ALTER TABLE KeyWord ADD "GROUP" VARCHAR(255)
      1341 TRACE [main] openjpa.jdbc.SQL - <t 706835911, conn 352584430> [31 ms] spent
      Exception in thread "main" <openjpa-2.2.3-SNAPSHOT-r422266:1595313 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Column 'GROUP' already exists in Table/View '"APP"."KEYWORD"'.

      {stmnt 1628232398 ALTER TABLE KeyWord ADD "GROUP" VARCHAR(255)} [code=30000, state=X0Y32]
      at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:559)
      at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:455)
      at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:160)
      at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:164)
      at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:122)
      at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:209)
      at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
      at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
      at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:51)
      at com.ibm.ws.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:35)
      at test.Main.main(Main.java:16)
      Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Column 'GROUP' already exists in Table/View '"APP"."KEYWORD"'. {stmnt 1628232398 ALTER TABLE KeyWord ADD "GROUP" VARCHAR(255)}

      [code=30000, state=X0Y32]
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:219)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:203)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:59)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:914)
      at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:118)
      at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1224)
      at org.apache.openjpa.jdbc.schema.SchemaTool.addColumn(SchemaTool.java:1057)
      at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:506)
      at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:366)
      at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:343)
      at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:505)
      ... 10 more

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              allee8285 Albert Lee

              Dates

              • Created:
                Updated:

                Issue deployment