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

java.sql.SQLException when processing a query result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.1, 2.2.2, 2.3.0, 2.4.0
    • 2.1.2, 2.2.1.1, 2.2.3, 2.4.0
    • jdbc
    • None

    Description

      We encountered the following stacktrace[1] when processing the results of a very complex query.

      After much debugging I found that the net of the problem is that in SelectImpl we cache column aliases(cachedColumnAlias_) keyed off a given org.apache.openjpa.jdbc.schema.Column, but a given column might map to multiple aliases(depending on the PathJoins @see SelectImpl.SelectResult.containsInternal). It appears that under normal circumstances it is okay that we continually overwrite aliases, but for this one query we were incorrectly mapping to the wrong alias. I unsuccessfully attempted to write a unit test for a good day and I've given up on providing a unit tests.

      Committers :: please feel free to review this commit to ensure that I'm not regressing an behavior.

      [1] <openjpa-2.1.2-SNAPSHOT-r422266:1530146 fatal general error> org.apache.openjpa.persistence.PersistenceException: t1.FK
      FailedObject: [....].jpa.people.Person-C-BBHJ897 [java.lang.String]
      at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4925)
      at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4885)
      at org.apache.openjpa.jdbc.sql.DB2Dictionary.newStoreException(DB2Dictionary.java:603)
      at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)
      at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:86)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:338)
      at com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCStoreManager.initialize(WsJpaJDBCStoreManager.java:149)
      at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
      at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
      at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1027)
      at com.ibm.ws.persistence.kernel.WsJpaBrokerImpl.initialize(WsJpaBrokerImpl.java:257)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:985)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:907)
      at com.ibm.ws.persistence.kernel.WsJpaBrokerImpl.find(WsJpaBrokerImpl.java:199)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1041)
      at com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCStoreManager.load(WsJpaJDBCStoreManager.java:112)
      at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
      at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2381)
      at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.loadEagerJoin(RelationFieldStrategy.java:724)
      at org.apache.openjpa.jdbc.meta.FieldMapping.loadEagerJoin(FieldMapping.java:922)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1111)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1067)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:438)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:333)
      at com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCStoreManager.initialize(WsJpaJDBCStoreManager.java:149)
      at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
      at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57)
      at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1027)
      at com.ibm.ws.persistence.kernel.WsJpaBrokerImpl.initialize(WsJpaBrokerImpl.java:257)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:985)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:907)
      at com.ibm.ws.persistence.kernel.WsJpaBrokerImpl.find(WsJpaBrokerImpl.java:199)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1041)
      at com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCStoreManager.load(WsJpaJDBCStoreManager.java:112)
      at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
      at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2381)
      at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:274)
      at org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
      at org.apache.openjpa.kernel.QueryImpl$PackingResultObjectProvider.getResultObject(QueryImpl.java:2075)
      at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:36)
      at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1251)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1007)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
      at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
      at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:315)
      at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:331)
      ....
      Caused by:
      java.sql.SQLException: t1.FK
      at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.findObject(SelectImpl.java:2507)
      at org.apache.openjpa.jdbc.sql.ResultSetResult.translate(ResultSetResult.java:497)
      at org.apache.openjpa.jdbc.sql.AbstractResult.getString(AbstractResult.java:767)
      at org.apache.openjpa.jdbc.meta.strats.StringFieldStrategy.getPrimaryKeyValue(StringFieldStrategy.java:217)
      at org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:188)
      at org.apache.openjpa.jdbc.meta.ClassMapping.getObjectId(ClassMapping.java:147)
      at org.apache.openjpa.jdbc.meta.strats.RelationFieldStrategy.load(RelationFieldStrategy.java:754)
      at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:928)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1123)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1067)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:438)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:333)
      ... 150 more

      Attachments

        Activity

          People

            curtisr7 Richard G. Curtis
            curtisr7 Richard G. Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: