-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate and MySQL issues with BOOLEAN/BIT
PostPosted: Thu Oct 27, 2005 10:20 am 
Newbie

Joined: Thu Oct 27, 2005 10:06 am
Posts: 1
Hibernate version: 3.1

All,

I've run into an issue that I've seen posted here, but I haven't seen a resolution for it.

Per MySQL's documentation, http://dev.mysql.com/doc/refman/5.0/en/ ... rview.html, MySQL 5.0.3 no longer converts a BIT to a TINYINT(1). That's problematic because the Hibernate MySQLDialect converts BOOLEAN to BIT, which was proper prior to MySQL 5.0.3.

The issue has caused problems in my deployment of JBoss Portal. I've fixed the issue by inserting the Portal tables by hand using answers from the great oracle Google. However, I'm still wondering if this is an issue that is going to be addressed in a future version of Hibernate. I would suggest just converting the BOOLEAN to TINYINT(1) in the MySQLDialect. That should remedy the problem for most current versions of MySQL.

I'm a Hibernate newbie, so if there's a way that I can change something on my end to make this happen automatically, I would love to learn how to do that.

Thanks,
Talib

_________________
Talib Morgan
Actuan -- New Strategies for Digital Media
http://www.actuan.com


Top
 Profile  
 
 Post subject: Ran into same issue
PostPosted: Thu Oct 27, 2005 2:46 pm 
Beginner
Beginner

Joined: Thu Jun 23, 2005 4:11 pm
Posts: 24
The way I worked around is the following:

<property name="name" type="boolean">
<column name="name" sql-type="tinyint" not-null="true"/>
</property>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 11:22 am 
Beginner
Beginner

Joined: Sun Dec 14, 2003 10:47 am
Posts: 23
We have this same issue. We use xdoclet to create out .hbm.xml files. We support several databases and do several schema mods depending on the db. We accomplish this by post processing the .hbml.xml files. In this case we simply map all the boolean types to sql-type="tinyint"...

I am wondering if creating a Mysql5Dialect would fix the problem. We have created customer dalects before and it isn't that hard to do. Particularly in this case simply extend mysqldialect and override the single behaviour...

When/if I try creating a mysql5dialect I will post here the results...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 12:25 pm 
Beginner
Beginner

Joined: Sun Dec 14, 2003 10:47 am
Posts: 23
Well I looked at the MysqlDialect... Noticed for the first time an Innodb and a MyIsam dialect which is good to know since for some things Mysql behaves quite differently depending on the table type...

I couldn't find a simple way to do this in the dialect... So I am simply using hte post processing step I mentioned before where we just add a column tag to all boolean...

<column name='xyz' sql-type='tinyint' not-null='true' />


For Boolean (non-primitve) we add this


<column name='xyz' sql-type='tinyint' not-null='false' />


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.