• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Boolean mapping

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nobody?
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic