-->
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.  [ 2 posts ] 
Author Message
 Post subject: Jboss 7 & Hibernate 4 - boolean value in mysql
PostPosted: Wed Aug 17, 2011 1:37 pm 
Newbie

Joined: Wed Aug 17, 2011 1:29 pm
Posts: 1
Hello,

I am facing following problem. I have an entity that contains boolean field. In MySQL I define this field as bit(1) (in older versions of hibernate, boolean was mapped to bit(1) in mysql). With Hibernate 4 however, it throws following
Quote:
exception:
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1786)
at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_22]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_22]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_22]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: UNIT1] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:903)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:879)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:170)
at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:80)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
... 4 more
Caused by: org.hibernate.HibernateException: Wrong column type in blah.person for column locked. Found: bit, expected: boolean
at org.hibernate.mapping.Table.validateColumns(Table.java:281)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1264)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:449)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1720)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:77)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:894)
... 9 more


boolean in mysql is mapped to tinyint(1) but it returns the same result. Note that I specify validation of a scheme in persistence.xml as follows:
Quote:
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="validate"/>


Any suggestions?

Thanks


Top
 Profile  
 
 Post subject: Re: Jboss 7 & Hibernate 4 - boolean value in mysql
PostPosted: Fri Jan 13, 2012 9:44 am 
Newbie

Joined: Mon Dec 01, 2008 1:40 pm
Posts: 5
You may remap the boolean java type mapping to be again a bit(1) type using a custom dialect:

registerColumnType(Types.BOOLEAN, "bit(1)");

Not a good solution but a workaround for upgrade path hibernate 3.6 -> hibernate 4.
Theres also a issue raised for this here: https://hibernate.onjira.com/browse/HHH-6935


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.