[英]org.hibernate.exception.SQLGrammarException: could not get next sequence value
Am using Hibernate 3.6 我正在使用Hibernate 3.6
Below is Employee
class code. 以下是
Employee
类代码。
public class Employee {
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
Below is Employee.hbm.xml
file, 以下是
Employee.hbm.xml
文件,
<class name="com.testing.hibernate.Employee" table="HIB_EMPLOYEE">
<meta attribute="class-description">
This class contains the Employee details.
</meta>
<id name="id" type="int" column="id">
<generator class="sequence"></generator>
</id>
<property name="firstName" column="first_name" type="string"></property>
<property name="lastName" column="last_name" type="string"></property>
<property name="salary" column="salary" type="int"></property>
</class>
I have created sequence in Database. 我已经在数据库中创建了序列。 Below SS for reference.
下面以SS为参考。 How can I overcome the exception that am getting?
我该如何克服正在出现的异常?
You have to give the reference of the sequence to hibernate. 您必须提供要休眠的序列的参考。
<generator class="sequence">
<param name="sequence">SEQUENCE_NAME</param>
</generator>
What annotation can i use to do this? 我可以使用什么注释来做到这一点?
i've tried 我试过了
@GeneratedValue(strategy=GenerationType.SEQUENCE , generator = <SEQUENCE_NAME>")
without any success @GeneratedValue(strategy=GenerationType.SEQUENCE , generator = <SEQUENCE_NAME>")
没有成功
edit: 编辑:
it seams that the generator have to also be created 它表明必须也必须创建发电机
@SequenceGenerator(name="<GEN_NAME>", sequenceName="<SEQUENCE_NAME>")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.