title: Updating replaced OneToMany ArrayList's cascade objects of an entity
body: <p>I am using PlayFramework 2.2.1 / Java / Ebean / MySQL<br>
  Thera are two classes (entities):</p>
  
  <pre><code>@Entity
  public class Cart extends Model{
      @Id @GeneratedValue
      public int id;
      @OneToMany(cascade=CascadeType.ALL)
      public List &lt;Item&gt; items = new ArrayList&lt;&gt;();
  }
  
  @Entity
  public class Item extends Model{
      @Id @GeneratedValue
      public int id;
      public String name;
  }
  </code></pre>
  
  <p>I'm trying to update existing records in DB table with changes I make to Item objects inside ArrayList of Cart object.<br>
  Problem - Ebean doesn't update, but adds a new record in table if I <strong>replace object</strong> in items ArrayList, but it does update existing record if I <strong>change field values</strong> of an Item object directly:</p>
  
  <pre><code>    Cart cart = new Cart();
      Item item1 = new Item(); item1.name = "Banana";
      Item item2 = new Item(); item2.name = "Peach";
      cart.items = new ArrayList&lt;Item&gt;();
      cart.items.add(item1);
      cart.items.add(item2);
      cart.save();
  </code></pre>
  
  <p>No problems with saving, but when I try to read and update:  </p>
  
  <pre><code>    Cart cart = Cart.find.all().get(0);
      cart.items.get(0).name="Orange";                //updates perfectly
      Item item3 = new Item(); item3.name = "Apple";  
      cart.items.set(1, item3);                       //adds additional third record
      cart.update();
  </code></pre>
  
  <p>What am I doing wrong?</p>