Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Boolean mapping  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings!

I'm using Netbeans, Glassfish V2 and MySQL 5 and the boolean map doesn't work



either if it's Boolean or boolean, always map to a TINYINT(1), I know that MySQL have a BOOLEAN type, how can I do that?

regards
 
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know the boolean mapping is not working? Is there a design time error message? A runtime error message.

This mapping works fine for Boolean values on MySQL through NetBeans and Eclipse.



What's the heart of the problem?

-Cameron McKenzie
 
alexandre nofre
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no, it doesn't give an error...

the problem is that in MySQL administrator I open the table and it is TINYINT(1), therefore I can put values like -1, 3, and so on
I just want to put true or false.. thats the problem, the direct acess, not the mapping, I want a BOOLEAN column

thanks
 
alexandre nofre
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nobody?
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm wondering what would happen if you just set the data-type in MySQL to a boolean type, and then ran your code. Would Hibernate hick-up, demanding a TinyInt, or would it just run well.

Of course, it doesn't solve the mapping to database creation problem, but it would be interesting.

-Cameron McKenzie
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
MYSQL supports boolean data type. You can either use BOOL or Boolean or TINYINT(1).
Thanks
Sudha
 
alexandre nofre
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sudha: I know that, my problem is that the toplink.ddl-generation creates a table with a TINYINT type instead my field type boolean, capiche?

Cameron:
I treat that field in my java code giving values true or false, and its persisted in table as 1 or 0. Everything works, but I still have to add and check operation in mysql to avoid direct insertion (I mean directly in mysql administrator for example)

regards
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
ScroogeXHTML - the small and fast RTF to HTML converter library
https://coderanch.com/t/707504/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!