Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 8.0-RC2
-
Component/s: jdbc
-
Labels:None
-
Environment:HideApache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: c:\Program Files\apache-maven-3.0.4\bin\..
Java version: 1.6.0_29, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_29\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"ShowApache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100) Maven home: c:\Program Files\apache-maven-3.0.4\bin\.. Java version: 1.6.0_29, vendor: Sun Microsystems Inc. Java home: C:\Program Files\Java\jdk1.6.0_29\jre Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Description
To recognize autoincrement on primary columns in oracle (sequence + insert trigger) I use the pk metatable capabilities of geotools. Because of naming conventions this table needs to be renamed so I specified the custom name (without schema name) via property as followed:
Find datastore with custom pk metatable
Map<String, Object> params = new HashMap<String, Object>(); params.put(JDBCDataStoreFactory.DBTYPE.key, "oracle"); params.put(JDBCJNDIDataStoreFactory.JNDI_REFNAME.key, DATASOURCE_JNDI_NAME); params.put(JDBCDataStoreFactory.PK_METADATA_TABLE.key, "CUSTOM_TABLE_NAME"); //table name without schema JDBCDataStore datastore = (JDBCDataStore)DataStoreFinder.getDataStore(params);
The resultant statement looks like this: SELECT * FROM CUSTOM_TABLE_NAME.GT_PK_METADATA
The reason is located in JDBCDataStoreFactory:
org.geotools.jdbc.JDBCDataStoreFactory.java:199
String metadataTable = (String) PK_METADATA_TABLE.lookUp(params); if(metadataTable != null) { MetadataTablePrimaryKeyFinder tableFinder = new MetadataTablePrimaryKeyFinder(); if(metadataTable.contains(".")) { //... } else { tableFinder.setTableSchema(metadataTable); // THIS IS WRONG // should be: tableFinder.setTableName(metadataTable); } //... }
Instead of setting the table name the schema name gets modified.
I hope somebody can fix it quickly because setting the schema prior as configuration is not applicable for me (jndi connection configuration allows change of database without touching source code).