-->
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: Migration woes - Cannot find data type boolean
PostPosted: Mon Oct 24, 2011 7:33 pm 
Newbie

Joined: Mon Oct 24, 2011 6:32 pm
Posts: 1
Hello,

What has changed regarding the boolean data type between Hibernate 3.1.3 and Hibernate 4? I am in the process of migrating an application and I am running into the following error:

16:21:04,368 INFO [stdout] (Thread-25)
16:21:04,368 INFO [stdout] (Thread-25) create table Example (
16:21:04,368 INFO [stdout] (Thread-25) theId varchar(255) not null,
16:21:04,368 INFO [stdout] (Thread-25) name varchar(255) null,
16:21:04,368 INFO [stdout] (Thread-25) operational boolean null,
16:21:04,368 INFO [stdout] (Thread-25) primary key (theId)
16:21:04,383 INFO [stdout] (Thread-25) );

16:21:04,383 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (Thread-25) HHH00389:Unsuccessful: create table Example (theId varchar(255) not null, name varchar(255) null, operational boolean null, primary key (theId))
16:21:04,383 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (Thread-25) Column or parameter #3: Cannot find data type boolean.


The above messages appear when I try to export the schema to database using Hibernate 4.0.0.CR2 (which was included with JBoss AS 7.0.2).

I have reviewed the Hibernate migration guides here: http://community.jboss.org/wiki/Hiberna ... tionGuides and didn't see anything that would help. The application uses Hibernate configuration files, and the mapping file for my "Example" class looks like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.example.persistence">
   <class name="Example" table="Example">
      <id
         name="id"
         column="theId"
         type="string">
         <meta attribute="field-description">Primary key</meta>
         <generator class="assigned"/>
      </id>
      <property
         name="name"
         column="name"
         type="string">
      </property>
      <property
         name="operational"
         column="operational"
         type="boolean">
      </property>
   </class>
</hibernate-mapping>


Other data types, such as varchar(255), int, double, etc... all seem to be handled correctly. Have others seen this? Have I missed something obvious in a migration guide?

Updated 10/25/2011:
After further research and experimentation, I now have a solution that is allowing me to complete the schema export. Here's what I figured out, hopefully this information may prove useful to others with the same or similar problem...

The database being used is SQL Server 2000. Upon review of the supported data types from Microsoft for the product, I noticed that boolean wasn't an option. This was a surprise as the Hibernate configuration files I am working with specify a type of "boolean" in numerous places, and prior to upgrading to Hibernate 4.0.0.CR2, everything "just-worked". I can only speculate that something did change between Hibernate 3.1.3 and 4.0.0.CR2, as the Hibernate dialect we had been using was
Code:
org.hibernate.dialect.SQLServerDialect
. Earlier this morning I came across an article ( http://www.componentix.com/blog/5) that described a method to extend the SQLServerDialect to change the way types are handled.

My "old" database showed a column type of "tinyint" for columns that were boolean types, so in the constructor for my new instance of SQLServerDialect I added the following:

Code:
registerColumnType(Types.BOOLEAN, "tinyint");


I then modified our custom code that drives the Hibernate configuration process to use the new dialect, and voila, I can now export the schema successfully.


Brian


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.