I am using JPA2.0 and Hibernate 4
For generating primary key in table, I am using table trigger. Trigger works fine if I am using Long as data type for Primary Key. However if I am using String as Primary Key data type, then I am getting the following errors.
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)
So is it not allowed to use String for Primary Key for generating values using trigger?
My code snippet for generating values using trigger
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;
}