title: Ebean ManyToOne Mapping CRUD
body: <p>I have two Entities Transaction and Category with ManyToOne mapping. So many transaction can fall into have category.</p>
  
  <pre><code>@Entity
  class Transaction extends Model{
    @Id 
    public Long id;
  
    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name="cat_id", referencedColumnName="cat_id")
    public Category cat;
  }
  
  @Entity
  class Category extends Model{
  
   @Id
   @Column(name="cat_id")
   public Long catId;
  
   @Column(unique=true)     
   public String catName;
  
   @ManyToOne
   public List&lt;Transaction&gt; transactions
  
  }
  </code></pre>
  
  <p>Now, when I add two transactions with same catName twice, it throws Unique constraint failure on catName. Is there any way I can instruct Ebean to merge Category, if CatName already exists (instead of always trying to insert)?  </p>
  
  <p>Also is this mapping approach correct, considering following:<br>
    If I delete Transaction, corresponding Category should not be deleted as it may be referenced by other Transactions.</p>
  
  <p>Thanks for any help!</p>