Announcement Announcement Module
Collapse
No announcement yet.
Saven in table using JPA in STS Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    This is my service classes and the method save

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

    Comment


    • #3
      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

      Comment

      Working...
      X