• Post Reply Bookmark Topic Watch Topic
  • New Topic

MySQL Hibernate, issue with storing boolean value  RSS feed

Bala Gangadhar
Ranch Hand
Posts: 119
  • 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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!