Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: hsql 1.8.0 and hbm2ddl.auto validate
PostPosted: Tue Jan 10, 2006 5:07 am 
Newbie

Joined: Tue Jan 10, 2006 4:36 am
Posts: 1
Hibernate version: 3.1 12.12.2005
Full stack trace of any exception that occurs:
[junit] org.hibernate.HibernateException: Wrong column type: enabled, expected: bit
[junit] at org.hibernate.mapping.Table.validateColumns(Table.java:219)
[junit] at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:964)
[junit] at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
[junit] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)
[junit] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1154)
[junit] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:800)
[junit] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:726)

Name and version of the database you are using: HSQLDB 1.8.0.1

Hibernate 3.1 hsql dialect supports HSQLDB version 1.8 and higher, only.

There seams to be an issue with any property with a boolean type when
hibernate.hbm2ddl.auto is set to validate.
(property name="enabled" type="boolean" column="enabled")


The issue is in org/hibernate/dialect/HSQLDialect.java line 32:
registerColumnType( Types.BIT, "bit" );
changing the line to:
registerColumnType( Types.BIT, "boolean" );
solves the problem.

Is this an issue of hibernate or hsqldb?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 11:14 am 
Newbie

Joined: Mon Sep 04, 2006 9:03 am
Posts: 9
I have the same problem. Is there a BUG report anywhere?

Alex

EDIT: BUG is here: http://opensource.atlassian.com/project ... e/HHH-1598


Top
 Profile  
 
 Post subject: Fix the bug with a subclass for the original HSQLDialect
PostPosted: Fri Jan 26, 2007 5:59 am 
Newbie

Joined: Fri Jan 26, 2007 5:52 am
Posts: 2
If you do not want to replace the line you can override the setting made by the original class in a subclass like this.

Code:
public class HSQLDialect_HHH_1598 extends org.hibernate.dialect.HSQLDialect {

    public HSQLDialect_HHH_1598() {
        super();
        registerColumnType(Types.BIT, "boolean");

        // Assert that the new type is registered correctly.
        if (!"boolean".equals(getTypeName(Types.BIT))) {
            throw new IllegalStateException("Failed to register HSQLDialect "
                    + "column type for Types.BIT to \"boolean\".");
        }
    }
}


Just replace the value for hibernate.dialect with the name of this class.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 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.