Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MySQL Hibernate, issue with storing boolean value  RSS feed

 
Ranch Hand
Posts: 123
2
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!