title: how to avoid updating parent in JPA Hibernate One-to-Many
body: <p>I made a project that using spring + hibernate (JPA Mapping). I'm using One-to-Many JPA Hibernate. i don't know whether my design itself wrong or what. I have two class Useradmin (Parent) and Tanya (child). from this i need to get the records from another table by using properties of Useradmin (parent). when I insert new record for Tanya (child) the Useradmin (Parent) updated too. I just want to insert into Tanya (child) whitout insert or update the Useradmin (Parent). could any body give me a solution, please suggest the idea to proceed :)</p>
  
  <p>this is my Useradmin Class : </p>
  
  <pre><code>@SuppressWarnings("serial")
  @Entity
  @Table(name="user")
  public class UserAdmin implements Serializable{
  
  @Id
  @Column(name="no_dana", unique=true, nullable=false, updatable=false)
  private String no_dana;
  
  @Column(name="npp")
  private String npp;
  
  @Column(name="password")
  private String password;
  
  @Column(name="nama_depan")
  private String nama_depan;
  
  @Column(name="nama_tengah")
  private String nama_tengah;
  
  @Column(name="nama_belakang")
  private String nama_belakang;
  
  @Column(name="kota")
  private String kota;
  
  @OneToMany(cascade=CascadeType.ALL, mappedBy="useradmin")
  private Set&lt;Tanya&gt; tanya  = new HashSet&lt;Tanya&gt;(0);
  
  /**other field**//
  
  /**setter and gettter methods**/
  }
  </code></pre>
  
  <p>this is my Tanya Class : </p>
  
  <pre><code>@SuppressWarnings("serial")
  @Entity
  @Table(name="tanya")
  public class Tanya implements Serializable{
  
  @Id
  @Column(name="id_tanya", unique=true, nullable=false)
  private int id_tanya;
  
  @Column(name="subject")
  private String subject;
  
  @Column(name="isi")
  private String isi;
  
  @Temporal(TemporalType.TIMESTAMP)
  @Column(name="created")
  private Date created;
  
  @ManyToOne(cascade=CascadeType.ALL)
  @JoinColumn(name="no_dana")
  private UserAdmin useradmin;
  
  /**other field**//
  
  /**setter and gettter methods**/
  }
  </code></pre>
  
  <p>and this is my controller  :</p>
  
  <pre><code>@RequestMapping("/user/tanya-jawab.html")
  public ModelAndView listTanyaJawab(ModelMap model)throws Exception
  {
      User user           = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
      String sessionUser  = user.getUsername();
  
      try{
          UserAdmin dataUser = userService.get(sessionUser);
          model.addAttribute("userData", dataUser);
      } catch(Exception e){
          e.printStackTrace();
      }
  
      ModelAndView mav = new ModelAndView("usr-tanya");
      List&lt;Tanya&gt; tanyajawab = tanyaService.listAllTanya();
      mav.addObject("tanyajawab", tanyajawab);
      return mav;
  }
  
  @RequestMapping(value="/user/add-tanya-jawab.html", method=RequestMethod.POST)
  public ModelAndView addTanyaJawab(@ModelAttribute Tanya tanya, ModelMap model, HttpServletRequest request, HttpServletResponse response)throws Exception
  {
      String userName = request.getParameter("hiddenUsername");
  
      UserAdmin useradmin = new UserAdmin();
      useradmin.setNo_dana(userName);
      System.out.println("ini"+userName);     
      java.util.Date date = new java.util.Date();
  
      tanya.setUseradmin(useradmin);
      tanya.setCreated(date);
      tanyaService.save(tanya);       
  
      return listTanyaJawab(model);
  }
  </code></pre>
  
  <p>any help will be pleasure :)</p>