Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java boolean is not handled correctly when used with Oracle JDBC driver [SPR-14116] #18688

Closed
spring-issuemaster opened this issue Apr 5, 2016 · 1 comment
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Apr 5, 2016

Igor Voshkulat opened SPR-14116 and commented

Database field is defined as NUMBER(1,0).
Model object with a boolean field is mapped to parameters via SqlParameterSourceUtil.createBatch().

In version 3.2.2.RELEASE StatementCreationUtils.javaTypeToSqlTypeMap had no mapping for java boolean (more precisely it was commented out) and was working fine. This resulted in StatementCreationUtils.setValue() to execute ps.setObject(paramIndex, inValue).

After boolean mapping was uncommented ps.setObject(paramIndex, inValue, sqlType) is used.

Oracle doesn't have proper matching boolean type, however driver is smart enough to do automatic conversion from boolean to NUMBER.

Therefore following statements are valid:
ps.setObject(1, true);
ps.setBoolean(1, true);
ps.setObject(1, true, Types.NUMERIC); //very narrow-minded, works for this particular case but not generic enough

What is currently done:
ps.setObject(1, true, Types.BOOLEAN);

Which fails with invalid column type 17004.


Affects: 4.2.5

Issue Links:

  • #19150 'Invalid column type' exception generated when writing a Boolean data member to Oracle database ("is duplicated by")
  • #17488 Regression in handling of String passed as Types.OTHER to JdbcTemplate
  • #18398 Oracle 12c JDBC driver throws inconsistent exception from getParameterType (affecting setNull calls)
  • #16854 INSERT SELECT of large CLOB causes ORA-01461 on setString
  • #16223 JdbcTemplate should support JDBC 4.1 getObject(columnIndex, type)

Referenced from: commits 797f5db, 6b0f26c

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 5, 2016

Juergen Hoeller commented

Thanks for raising this! We're explicitly calling PreparedStatement.setBoolean for Types.BOOLEAN now, which seems to be a sensible processing path in any case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.