This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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?