StatementCreatorUtils.setValue only uses setString etc for Types.OTHER in case of Oracle
Issue: SPR-12890
This commit is contained in:
parent
10a51a4f19
commit
050e581c10
|
@ -410,7 +410,8 @@ public abstract class StatementCreatorUtils {
|
|||
ps.setObject(paramIndex, inValue, Types.TIMESTAMP);
|
||||
}
|
||||
}
|
||||
else if (sqlType == SqlTypeValue.TYPE_UNKNOWN || sqlType == Types.OTHER) {
|
||||
else if (sqlType == SqlTypeValue.TYPE_UNKNOWN || (sqlType == Types.OTHER &&
|
||||
"Oracle".equals(ps.getConnection().getMetaData().getDatabaseProductName()))) {
|
||||
if (isStringValue(inValue.getClass())) {
|
||||
ps.setString(paramIndex, inValue.toString());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -38,11 +38,13 @@ public class StatementCreatorUtilsTests {
|
|||
|
||||
private PreparedStatement preparedStatement;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
preparedStatement = mock(PreparedStatement.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSetParameterValueWithNullAndType() throws SQLException {
|
||||
StatementCreatorUtils.setParameterValue(preparedStatement, 1, Types.VARCHAR, null, null);
|
||||
|
@ -264,9 +266,15 @@ public class StatementCreatorUtilsTests {
|
|||
|
||||
@Test // SPR-8571
|
||||
public void testSetParameterValueWithStringAndVendorSpecificType() throws SQLException {
|
||||
Connection con = mock(Connection.class);
|
||||
DatabaseMetaData dbmd = mock(DatabaseMetaData.class);
|
||||
given(preparedStatement.getConnection()).willReturn(con);
|
||||
given(dbmd.getDatabaseProductName()).willReturn("Oracle");
|
||||
given(con.getMetaData()).willReturn(dbmd);
|
||||
StatementCreatorUtils.setParameterValue(preparedStatement, 1, Types.OTHER, null, "test");
|
||||
verify(preparedStatement).setString(1, "test");
|
||||
}
|
||||
|
||||
@Test // SPR-8571
|
||||
public void testSetParameterValueWithNullAndVendorSpecificType() throws SQLException {
|
||||
StatementCreatorUtils.setParameterValue(preparedStatement, 1, Types.OTHER, null, null);
|
||||
|
|
Loading…
Reference in New Issue