• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Weird implementation

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic