Results 1 to 3 of 3

Thread: Saven in table using JPA in STS

  1. #1
    Join Date
    May 2012
    Posts
    14

    Default Saven in table using JPA in STS

    I´m trying to save an entry from a form using JPA+Hibernat, but the following error message comes up:

    GRAVE: El Servlet.service() para el servlet [appServlet] en el contexto con ruta [/GoodProject] lanzó la excepción [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: org.hibernate.PropertyAccessException: could not set a field value by reflection setter of com.duckranger.goodproject.domain.Tramp.id; nested exception is javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not set a field value by reflection setter of com.duckranger.goodproject.domain.Tramp.id] con causa raíz
    java.lang.IllegalArgumentException: Can not set java.lang.Long field com.duckranger.goodproject.domain.Tramp.id to org.hibernate.id.IdentifierGeneratorHelper$2

    This is the method Controller:

    @RequestMapping(value = "/tramps", method = RequestMethod.POST, params="po4")
    public String saveJPA(Model model, HttpServletRequest request) {
    logger.info("Saving... Tramp in JPA");
    Tramp tramp = new Tramp();
    tramp.setName(request.getParameter("name"));
    tramp.setDistance(12.4);
    tramp.setDifficulty(null);
    //model.addAttribute("tramps", trampsService.save(tramp));
    tramp = trampsService.save(tramp);
    return "tramps/add";
    }

    Which is the problem?

    Thank you very much for your help

  2. #2
    Join Date
    May 2012
    Posts
    14

    Default

    This is my service classes and the method save

    public Tramp save(Tramp t) {
    return trampRepository.save(t);
    }

  3. #3
    Join Date
    Sep 2008
    Location
    Hamburg, Germany
    Posts
    1,637

    Default

    Hey!

    I thought I already moved this from the STS group to another one, but it looks like I was wrong. So I moved it now into the Data forum since I guess it is a better fit. The question doesn't seem to be tooling related.

    HTH,
    Martin
    Martin Lippert
    SpringSource, a division of VMware
    SpringSource Tools Team
    http://www.springsource.com
    http://twitter.com/martinlippert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •