-->
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.  [ 1 post ] 
Author Message
 Post subject: Boolean in Mysql saved as Bit
PostPosted: Mon Jul 10, 2006 6:48 am 
Newbie

Joined: Tue Apr 25, 2006 2:08 am
Posts: 7
Hi All

I am using hibernate to save my beans to a mysql database. Everything works perfectly except a boolean value. I have it mapped like this

/*
*@hibernate.property column="Strict_Online"
*/
public boolean isStrictOnlineLeerling() {

When I execute my ant command and the database is created I see this in the log:

create table Member (UserID varchar(255) not null, Strict_Online bit .........
This works fine by the way.

When I call the method saveOrUpdate I get the following error:
Caused by: java.sql.BatchUpdateException: Data too long for column 'Strict_Online' at row 1


I think I know what the problem is. When I try and insert the member manually like this:
insert into Member values ('abcdefg', '1');
I get an error. But if I do this:
insert into Member values ('abcdefg', 1);
everything works fine.

I am getting the impression that hibernate likes to put ' around bit values in the database which according to my mysql server version (5.0) isnt allowed.

I have tried the following 3 dialects:
org.hibernate.dialect.MySQLDialect
org.hibernate.dialect.MySQLInnoDBDialect
org.hibernate.dialect.MySQLMyISAMDialect

I know there is a possibility to supply a own mapping file so that mysql could map to tinyint(1) with booleans but I would expect hibernate to do it right out of the box.

Any help would be appreciated.

Martyn


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

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.