Skip to content

SimpleJdbcInsert needs to understand synonyms! [SPR-4782] #9459

Closed
@spring-projects-issues

Description

@spring-projects-issues

C N opened SPR-4782 and commented

I'm using Spring 2.5.2 and Oracle 10g jdbc drive. This fails

SimpleJdbcInsert x = new SimpleJdbcInsert(dataSource).withTableName('ABC');
x.execute( ... );

when tableName is a synonym to a table in another schema. It won't follow the synonym! Prepending the schema name to the table name doesn't work either.

org.springframework.dao.InvalidDataAccessApiUsageE xception: Unable to locate columns for table 'ABC' so an insert statement can't be generated
org.springframework.jdbc.core.metadata.TableMetaDa taContext.createInsertString(TableMetaDataContext. java:299)
org.springframework.jdbc.core.simple.AbstractJdbcI nsert.compileInternal(AbstractJdbcInsert.java:257)
org.springframework.jdbc.core.simple.AbstractJdbcI nsert.compile(AbstractJdbcInsert.java:240)
org.springframework.jdbc.core.simple.AbstractJdbcI nsert.checkCompiled(AbstractJdbcInsert.java:291)
org.springframework.jdbc.core.simple.AbstractJdbcI nsert.doExecute(AbstractJdbcInsert.java:329)
org.springframework.jdbc.core.simple.SimpleJdbcIns ert.execute(SimpleJdbcInsert.java:102)

If you can cast java.sql.Connection to oracle.jdbc.OracleConnection, you can setIncludeSynonyms(true) which will cause DatabaseMetadata to understand synonyms.


Affects: 2.5.2

Referenced from: commits f70d14e

1 votes, 1 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions