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
|