Since the Postgres driver 42.7.5 PostgresTableMetaDataProvider no longer retrieves column metadata for databases which have an upper case in their name: org.springframework.dao.InvalidDataAccessApiUsageException: Unable to locate columns for table 'XXX' so an insert statement can't be generated. org.springframework.jdbc.core.metadata.TableMetaDataContext.createInsertString(TableMetaDataContext.java:351)
Before Postgres driver version 42.7.5 in method locateTableAndProcessMetaData of class GenericTableMetaDataProvider the table metadata returned no value for TABLE_CAT so later in processTableColumns also a null catalog name was provided and databaseMetaData.getColumns didn't filter by catalog name. Since 42.7.5 TABLE_CAT returns a value like abC which is then in processTableColumns transformed to abc by metaDataCatalogNameToUse and passed to databaseMetaData.getColumns . This then returns no value for a catalog name abc but would returnd columns with a catalog name abC. As the Javadoc says "must match the catalog name as it is stored in the database" and other projects like https://github.com/liquibase/liquibase/issues/6666 / https://github.com/pgjdbc/pgjdbc/issues/3560 fixed it in their code I believe that it is a bug in Spring JDBC and not in the Postgres JDBC Driver and that metaDataCatalogNameToUse should not change the catalog name retrieved from table metadata.
Comment From: jhoeller
Does it work when you explicitly call setStoresLowerCaseIdentifiers(false)
? It looks like the Postgres DatabaseMetaData.storesLowerCaseIdentifiers()
method returns true
, making GenericTableMetaDataProvider
convert identifiers to lower-case accordingly. This could be a bug in the Postgres JDBC driver where its metadata does not match its behavior anymore.