Uploaded image for project: 'GeoTools'
  1. GeoTools
  2. GEOT-5098

Primary Key Lookup fails for Oracle tables with underscores in their name

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 14-M0
    • Component/s: jdbc-oracle plugin
    • Labels:
      None
    • Environment:

      Oracle 11.2 running on Windows 2003 server.
      Issue was observed on various remote instances of GeoServer 2.7

      Description

      When inserting features into a table in an Oracle Datastore, if the table name contains underscores, then:
      The primary key lookup will fail:

      30 Apr 13:22:25 WARN [geotools.jdbc] - Failure occurred while looking up the primary key with finder: org.geotools.jdbc.HeuristicPrimaryKeyFinder@24cf7139
      java.sql.SQLException: Exhausted Resultset
      	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
      	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
      	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
      	at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:382)
      	at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:213)
      	at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:213)
      	at org.geotools.data.oracle.OracleDialect.getMapping(OracleDialect.java:254)
      	at org.geotools.jdbc.HeuristicPrimaryKeyFinder.createPrimaryKey(HeuristicPrimaryKeyFinder.java:108)
      	at org.geotools.jdbc.HeuristicPrimaryKeyFinder.getPrimaryKey(HeuristicPrimaryKeyFinder.java:59)
      	at org.geotools.jdbc.CompositePrimaryKeyFinder.getPrimaryKey(CompositePrimaryKeyFinder.java:52)
      	at org.geotools.jdbc.JDBCDataStore.getPrimaryKey(JDBCDataStore.java:1068)
      	at org.geotools.jdbc.JDBCFeatureSource.<init>(JDBCFeatureSource.java:94)
      	at org.geotools.jdbc.JDBCDataStore.createFeatureSource(JDBCDataStore.java:912)
      	at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:389)
      	at org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:370)
      	at org.geotools.data.store.ContentDataStore.ensureFeatureStore(ContentDataStore.java:451)
      	at org.geotools.data.store.ContentDataStore.getFeatureWriterAppend(ContentDataStore.java:483)
      	at org.geoserver.importer.Importer.loadIntoDataStore(Importer.java:1043)
      	at org.geoserver.importer.Importer.doIndirectImport(Importer.java:871)
      	at org.geoserver.importer.Importer.run(Importer.java:742)
      	at org.geoserver.importer.Importer.run(Importer.java:692)
      	at org.geoserver.importer.Importer$4.call(Importer.java:768)
      	at org.geoserver.importer.Importer$4.call(Importer.java:765)
      	at org.geoserver.importer.job.Job.call(Job.java:16)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      

      Because the primary key lookup fails, the primary key is null and we get a read-only FeatureSource, causing the insert to fail:

      java.io.IOException: NE_50M_ADMIN_0_COUNTRIES4 is read only
      	at org.geotools.data.store.ContentDataStore.ensureFeatureStore(ContentDataStore.java:453)
      	at org.geotools.data.store.ContentDataStore.getFeatureWriterAppend(ContentDataStore.java:483)
      	at org.geoserver.importer.Importer.loadIntoDataStore(Importer.java:1043)
      	at org.geoserver.importer.Importer.doIndirectImport(Importer.java:871)
      	at org.geoserver.importer.Importer.run(Importer.java:742)
      	at org.geoserver.importer.Importer.run(Importer.java:692)
      	at org.geoserver.importer.Importer$4.call(Importer.java:768)
      	at org.geoserver.importer.Importer$4.call(Importer.java:765)
      	at org.geoserver.importer.job.Job.call(Job.java:16)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:745)
      

      This is particularily notable when using the importer extension to import shapefiles.

      It looks like this error is related to the changes made here: https://github.com/geotools/geotools/commit/3a98d302b9f41006e33da51cc107ba7449e471f9 (Fix for GEOT-4912 Open )

      GEOT-4968 Open seems to be caused by a similar problem.

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                tbarsballe Torben Barsballe
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: