【发布时间】:2015-10-05 18:17:29
【问题描述】:
我正在使用 Hyperjaxb 生成我的 JPA 映射。然后我使用 hibernate3-maven-plugin 生成数据库的 SQL Script。我的问题在于我有一个类型,它的属性定义如下:
<xsd:element name="priority" type="xsd:boolean"/>
sql脚本这样定义列
PRIORITY bit,
而JPA实体是这样定义的
/**
* Obtient la valeur de la propriété priority.
*
*/
@Basic
@Column(name = "PRIORITY")
public boolean isPriority() {
return priority;
}
/**
* Définit la valeur de la propriété priority.
*
*/
public void setPriority(boolean value) {
this.priority = value;
}
我使用 MySql 作为后端。当我的 JPA/Hibernate entityManager 尝试针对数据库验证我的 JPA 模型时,就会出现问题。然后我得到这个错误
org.hibernate.HibernateException: Wrong column type in custom.sample_type for column PRIORITY. Found: bit, expected: boolean
如何解决此错误?在我读到的某个地方,我可以在 java 代码中做这样的事情
@Basic
@Column(name = "B", columnDefinition = "BIT", length = 1)
public boolean isB() {
return b;
}
但是我的 JPA java 代码是由 Hyperjaxb 自动生成的,那么如何使用 Hyperjaxb 实现类似的功能呢?
【问题讨论】:
标签: java mysql hibernate jpa hyperjaxb