Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boolean mapping

 
alexandre nofre
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
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
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
Saloon Keeper
Posts: 4968
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
 
sudha swami
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic