Skip to content

AbstractJdbcInsert failes with SqlLobValue type parameters [SPR-7199] #11858

@spring-projects-issues

Description

@spring-projects-issues

Alexander Nesterov opened SPR-7199 and commented

SimpleJdbcInsertOperations.executeAndReturnKey() call fails if there is any SqlLobValue parameter passed as a value to SQL request.

Seems that the problem is in AbstractJdbcInsert.setParameterValues() method, which incorrectly parses parameter types, setting them all to TYPE_UNKNOWN even if types are properly specified.

To corrent the problem the following code in setParameterValues() should be modifed:

if (columnTypes == null || colIndex < columnTypes.length) {
StatementCreatorUtils.setParameterValue(preparedStatement, colIndex, SqlTypeValue.TYPE_UNKNOWN, value);
}

->

if (columnTypes == null || colIndex > columnTypes.length) {
StatementCreatorUtils.setParameterValue(preparedStatement, colIndex, SqlTypeValue.TYPE_UNKNOWN, value);
}


Affects: 3.0.2

Referenced from: commits d22a6f9

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions