title: Hibernate - How to persist only the parent, keeping the children as they are
body: <p>Can someone please help me understand how to configure hibernate to do what i want.</p>
  
  <p>I have a parent entity "Appartment" with a List of "Room"s as children.
  I have a form to edit "Appartment"s and within that form i have listed all of the children "Room"s just for informative purposes. Rooms are added and edited in a separate form.</p>
  
  <p>So because i am listing the rooms in the appartment-form i have set lazyloading to false:</p>
  
  <pre><code>    @OneToMany
  @JoinColumn (name = "appartmentId")
  @LazyCollection (LazyCollectionOption.FALSE)
  private List&lt;Room&gt; room;
  </code></pre>
  
  <p>But if I edit an appartment and store it, all the appartments rooms suddenly dissappear. In the database they are not deleted, but dereferenced (as in appartmentId = null).</p>
  
  <p>So how can I configure hibernate to only persist my Appartment-object. And not touch the children at all?</p>
  
  <p>This is my save-action:</p>
  
  <pre><code>public String save() throws Exception {
      boolean isNew = (appartment.getAppartmentId() == null);
  
      appartment = appartmentManager.save(appartment);
  
      String key = (isNew) ? "appartment.added" : "appartment.updated";
      saveMessage(getText(key));
  
      return SUCCESS;
  }
  </code></pre>