【发布时间】:2013-05-11 09:02:37
【问题描述】:
我正在使用 JPA2.0 和 Hibernate 4
为了在表中生成主键,我使用的是表触发器。如果我是,触发器可以正常工作 使用 Long 作为主键的数据类型。但是,如果我使用字符串作为主键 数据类型,然后我收到以下错误。
org.springframework.orm.hibernate3.HibernateSystemException: Unknown integral
data type for ids : java.lang.String; nested exception is
org.hibernate.id.IdentifierGenerationException: Unknown integral
data type for ids : java.lang.String at
org.springframework.orm.hibernate3.SessionFactoryUtils.
convertHibernateAccessException(SessionFactoryUtils.java:690)
那么是不是不允许使用String作为主键来使用触发器生成值?
我的代码 sn-p 用于使用触发器生成值
private String deptNo;
@Id
@GenericGenerator(name = "trig", strategy = "increment")
@GeneratedValue(generator = "trig")
@Column(name = "DEPT_NO")
public String getDeptNo() {
return deptNo;
}
public void setDeptNo(String deptNo) {
this.deptNo = deptNo;
}
【问题讨论】: