初值@TableGenerator的属性显示问题,休眠,但不是在JPA [英] initialValue attribute of @TableGenerator shows issue in Hibernate but not in JPA
本文介绍了初值@TableGenerator的属性显示问题,休眠,但不是在JPA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
package com.sb.firstjpaexample.pojo;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
@Entity
@Table(name = "EMPLOYEE")
public class Employee {
@Id
@TableGenerator(name = "TABLE_GEN", table = "SEQUENCE_TABLE", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "EMP_SEQ", initialValue = 1001, allocationSize = 5)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "TABLE_GEN")
private int employeeId;
@Column
private String employeeName;
@Column
private String designation;
@Column
private double salary;
public int getEmployeeId() {
return employeeId;
}
public void setEmployeeId(int employeeId) {
this.employeeId = employeeId;
}
public String getEmployeeName() {
return employeeName;
}
public void setEmployeeName(String employeeName) {
this.employeeName = employeeName;
}
public String getDesignation() {
return designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
}
这POJO需要的初始值1001 JPA,但在Hibernate中取1为初始值
还有一个疑问,如何设定增量步使用注释
在JPA它显示增量当我使用增量策略没有问题,但问题
"This POJO takes initial value as 1001 in JPA but takes 1 as initial value in Hibernate" One more doubt how to set increment step here using annotations In JPA it shows no problem but problem in increment when i use increment strategies
请帮助我,在此先感谢
推荐答案
我刚刚有同样的问题。它是错配与Hibernate老发电机和JPA。
I just had the same problem. It is the mis-matched with hibernate old generator and JPA.
您需要将它添加到你的config
You need to add this to your config
看到休眠DOC:的http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/ch01.html#d0e200
这篇关于初值@TableGenerator的属性显示问题,休眠,但不是在JPA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文