映射一个 tinyint 为 boolean 的 hibernate。
- 论坛
- 映射一个 tinyint 为 boolean 的 hibernate。
18 浏览
映射一个 tinyint 为 boolean 的 hibernate。
我在MySQL表中有一个BOOLEAN类型(TINYINT(1)),我正在尝试映射实体中的布尔字段,但这会生成一个异常:
org.hibernate.HibernateException:在maegul.users的admin列中找到了错误的列类型。找到:bit,期望:boolean
我将实体中的字段更改为字节,并进行相应的更改,以使其表现为布尔值,然后我得到:
org.hibernate.HibernateException:在maegul.users的admin列中找到了错误的列类型。找到:bit,期望:tinyint
我尝试在字段上使用@Type
注解:
@Type(type =“org.hibernate.type.NumericBooleanType”)
但是我得到:
org.hibernate.HibernateException:在maegul.users的admin列中找到了错误的列类型。找到:bit,期望:integer