• 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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: 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
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
 
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
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!