我想從Hibernate 3.6.5升級到4.0(並從Spring 3.0.5到Hibernate 4支持所需的3.1)。「發現:位,期望:布爾」後休眠4升級
現在,MySQL和HSQL,我遇到了此問題持續布爾字段:
Caused by: org.hibernate.HibernateException:
Wrong column type in PUBLIC.PUBLIC.EVENT for column Checked. Found: bit, expected: boolean
at org.hibernate.mapping.Table.validateColumns(Table.java:282)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1268)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:453)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:184)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:314)
JPA @Entity
和@Column
註釋域對象被使用,並且有問題的領域是這樣的:
@Column(name = "Checked")
private boolean checked;
HSQL模式:
Checked bit default 0 not null,
MySQL的架構:
`Checked` tinyint(1) NOT NULL default '0',
什麼是解決此同時與Hibernate 4堅持最簡單的方法是什麼?我應該更改數據庫模式,Hibernate配置還是域類註釋?
我不知道如果代碼和配置是完全「正確」之前,但至少它好工作與Hibernate 3
使用HSQL,在架構文件*中將「bit」更改爲「boolean」似乎有助於(即,然後我遇到不同的Hibernate 4問題)。這雖然有點奇怪,因爲[HSQL文檔](http://hsqldb.org/doc/guide/ch09.html#datatypes-部分)給人的印象是BOOLEAN和BIT是等價的。 – Jonik 2011-12-29 13:24:40