• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Sequence generation issue

Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get this exception when I am trying run a simple Spring MVC application insert/update to the Oracle database using Hibernate:
The retrieve works fine.
org.hibernate.exception.SQLGrammarException: could not get next sequence value.

I created a sequence for the table being refered to in the program.

The Model object has the code below:

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Table(name = "Article")
public class Article {

@Column(name = "Article_id")
private Long articleId;

@Column(name = "Article_name", nullable = false, length=20)
private String articleName;

@Column(name = "Article_desc", nullable = false)
private String articleDesc;

@Column(name = "Date_added")
private Date addedDate;

public Article() {

public Long getArticleId() {
return articleId;

public void setArticleId(Long articleId) {
this.articleId = articleId;

public String getArticleName() {
return articleName;

public void setArticleName(String articleName) {
this.articleName = articleName;

public String getArticleDesc() {
return articleDesc;

public void setArticleDesc(String articleDesc) {
this.articleDesc = articleDesc;

public Date getAddedDate() {
return addedDate;

public void setAddedDate(Date addedDate) {
this.addedDate = addedDate;

Also,the code which updates the DAO looks like this:

// To Save the article detail
public void saveArticle(Article article) {
//article.setArticleId(new Long(100));
article.setAddedDate(new Date());



Do I need a separate mapping file?

I am not sure.

Please advise.

Richard Ellison
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.I was able to resolve ths issue by using the @SequenceGenerator annotation.

That is a really big piece of pie for such a tiny ad:
a bit of art, as a gift, that will fit in a stocking
    Bookmark Topic Watch Topic
  • New Topic