This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Hibernate - SQLGrammarException : could not get next sequence value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate - SQLGrammarException : could not get next sequence value" Watch "Hibernate - SQLGrammarException : could not get next sequence value" New topic
Author

Hibernate - SQLGrammarException : could not get next sequence value

sanker san
Ranch Hand

Joined: Dec 17, 2004
Posts: 56
Hi,

I'm trying to use a sequence in the hibernate mapping. When I tried to insert a record into a table, it gave error while reading the value from sequence. The sequence exist in the database. The select query output by Hibernate is not correct. What am I doing wrong. The details of logs and mapping are given below:-

Logs:-
INFO: Echoing all SQL to stdout
Hibernate: select next value for slk_end_customer_id_seq from dual_slk_end_customer_id_seq
Error:-
exception occured..org.hibernate.exception.SQLGrammarException: could not get next sequence value
Mapping:-
<hibernate-mapping>
<class name="dao.Customer" table="SLK_END_CUSTOMER">
<id name="custid" column="END_CUSTOMER_ID">
<generator class="sequence">
<param name="sequence">slk_end_customer_id_seq</param>
</generator>
</id>

<property name="city" type="string" column="CITY"/>
</class>
</hibernate-mapping>

Thanks in advance
Sanker
sanker san
Ranch Hand

Joined: Dec 17, 2004
Posts: 56
It is resolved. I am using Oracle db and I had HSQLDialect instead of OracleDialect. I changed the following property and it worked.
Old
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
to New
<property name="dialect">org.hibernate.dialect.OracleDialect</property>

Thank you all
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate - SQLGrammarException : could not get next sequence value