Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

MySQL Hibernate, issue with storing boolean value

Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a boolean value in my Java class which is mapped to VARCHAR in mysql table.

When i store the values its getting stored as 1 or 0. But when i read it its always being read as false.

When i update the db value to 'true' or 'false' through a query and read it in Java, its perfectly read as true or false boolean value.

So inshort, my insert thorugh java is not working, i want it to be inserted as 'true' or 'false'.

But reading is working perfectly fine if DB has 'true' or 'false' strings.

Please advice me what settings are needed in .xml mapping file to store the boolean as 'true' or 'false' in mysql instead of 1 or 0.

Thanks a lot.
snakes are really good at eating slugs. And you wouldn't think it, but so are tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic