This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Weird implementation  RSS feed

Sripathi Krishnamurthy
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed a strange implementation in Spring 2.5.6 JDBC jar..

The underlying table has a column called TRANSACTION_FLAG which is varchar(1). So it takes only 1 char of data. But as you can see from the above code, transaction flag is a boolean.
But surprisingly, the above code worked perfectly fine in Spring 2.5.6. When run, it used to insert 0 or 1, based on the flag. How did this happen? How did Spring 2.5.6 automatically convert a boolean to 0 or 1? Did it read the column metadata and convert a boolean to fit in the column size? What if I needed a Y or N instead of 0 or 1?

When I upgraded to Spring 3.1.0 JDBC jar, the same logic failed. It gives the error column data too long for the column. I think this error is correct. Spring should not automatically convert anything from boolean to whatever it likes by reading column metadata.

Was it a bug in spring 2.5.6 JDBC which was fixed in 3.1.0 JDBC?

Please let me know your comments/suggestions.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!