Win a copy of Head First Android this week in the Android forum!
  • 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

Save is not performing in Spring Mvc 3Hibernate

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Article class
package net.devmanuals.model;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;

@Table(name = "imei")
public class Article {
@Column(name = "imei1",nullable = false)
private Long imeiNo;
@Column(name = "date_added")
private Date addedDate;

public Article() {

public Long getimei1() {
return imeiNo;

public void setimei1(Long imei1) {
this.imeiNo = imeiNo;

public Date getAddedDate() {
return addedDate;

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


package net.devmanuals.controller;

import java.util.HashMap;
import java.util.Map;

import net.devmanuals.model.Article;
import net.devmanuals.service.ArticleService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

public class ArticleController {

private ArticleService articleService;

@RequestMapping(value = "/save", method = RequestMethod.POST)
public ModelAndView saveArticle(@ModelAttribute(" article") Article article,
BindingResult result) {
articleService.addArticle( article);
return new ModelAndView("redirect:/articles.html");

@RequestMapping(method = RequestMethod.GET)
public ModelAndView listArticles() {

Map<String, Object> model = new HashMap<String, Object>();
model.put("articles", articleService.listArticles());

return new ModelAndView("articlesList", model);

@RequestMapping(value = "/add", method = RequestMethod.GET)
public ModelAndView addArticle(@ModelAttribute("article") Article article,
BindingResult result) {
return new ModelAndView("addArticle");


Article service:

package net.devmanuals.service;

import java.util.List;

import net.devmanuals.model.Article;

public interface ArticleService {

public void addArticle(Article article);

public List<Article> listArticles();

This Error comes when saving data,(But no error while displaying data)


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is ids for this class must be manually assigned before calling save(): net.devmanuals.model.Article
root cause ids for this class must be manually assigned before calling save(): net.devmanuals.model.Article
Posts: 17346
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is actually a Hibernate issue, not a Spring one.

But your mapping for the PK, id field is set up to be application assigned id. Meaning your code has to assign a new id to a new object.

You might want to add and @Generated…. annotation to your @Id mapping. I recommend reading the Hibernate Annotations documentation on ID mapping.

You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic