简体   繁体   English

org.hibernate.exception.SQLGrammarException:无法获取下一个序列值

[英]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.

相关问题 org.hibernate.exception.SQLGrammarException:无法提取ResultSet和错误:关系“ hibernate_sequence”不存在 - org.hibernate.exception.SQLGrammarException: could not extract ResultSet and ERROR: relation “hibernate_sequence” does not exist org.hibernate.exception.SQLGrammarException:无法插入,使用mysql休眠 - org.hibernate.exception.SQLGrammarException: could not insert, hibernate with mysql 错误:ORA-02289:序列不存在 - org.hibernate.exception.SQLGrammarException:无法提取 ResultSet - ERROR: ORA-02289: sequence does not exist - org.hibernate.exception.SQLGrammarException: could not extract ResultSet 嵌套的异常是org.hibernate.exception.SQLGrammarException:无法执行查询 - nested exception is org.hibernate.exception.SQLGrammarException: could not execute query 如何解决 org.hibernate.exception.SQLGrammarException: 无法执行查询 - How to solve org.hibernate.exception.SQLGrammarException: could not execute query RuntimeException:org.hibernate.exception.SQLGrammarException:无法执行查询 - RuntimeException: org.hibernate.exception.SQLGrammarException: could not execute query org.hibernate.exception.SQLGrammarException:无法执行查询 - org.hibernate.exception.SQLGrammarException: could not execute query org.hibernate.exception.SQLGrammarException:无法执行语句 - org.hibernate.exception.SQLGrammarException: could not execute statement org.hibernate.exception.SQLGrammarException:无法提取 ResultSet - org.hibernate.exception.SQLGrammarException: could not extract ResultSet 无法提取结果集,org.hibernate.exception.SQLGrammarException - Could not extract Result set, org.hibernate.exception.SQLGrammarException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM