title: Mapping Collection of String and Enum with Ebean (Play 2.0)
body: <p>I have problems mapping a Collection of Strings and Enums in my entities. I have followed different advices, but nothing seem to work. I am using PlayFramework 2.0 and the provided Ebean as ORM.</p>
  
  <p>Here is an illustration class:</p>
  
  <pre><code>package models;
  
  import java.util.*;
  import javax.persistence.*;
  import play.db.ebean.Model;
  
  @Entity
  @Table(name = "foo")
  public class Foo extends Model {
  
      private static final long serialVersionUID = 1L;
  
      private enum FooBar {
          FOO, BAR;
      }
  
      @Id
      public Long id;
  
      @ElementCollection
      @Enumerated(EnumType.STRING)
      @CollectionTable(name = "bar_foobar", 
          joinColumns = @JoinColumn(name = "bar_id", 
              referencedColumnName = "id"))
      @Column(name = "foobar")
      public List&lt;FooBar&gt; fooBars;
  
      @ElementCollection(targetClass = String.class)
      @CollectionTable(name = "bar_strings", 
          joinColumns = @JoinColumn(name = "bar_id"))
      @Column(name = "string", nullable = false)    
      public List&lt;String&gt; listOfStrings;
  
      @Basic
      public List&lt;String&gt; listOfStrings2;
  
      // Attempt to circumvent the issue, but this gives a strange error
      //public String[] arrayOfString;
  }
  </code></pre>
  
  <p>The generated DDL when the application is started looks like this:</p>
  
  <pre><code>create table foo (
  id      bigint not null,
  constraint pk_foo primary key (id))
  ;
  </code></pre>
  
  <p>I would expect to see both the tables <code>bar_foobar</code> and <code>bar_strings</code> being created, if the annotations were correct.</p>
  
  <p>If using the <code>arrayOfString</code> variable, I get a weired error-message upon application launch (which related to a random entity, not necessarily Foo.class</p>
  
  <blockquote>
    <p>PersistenceException: Error with [models.user.User] It has not been
    enhanced but it's superClass [class play.db.ebean.Model] is? (You are
    not allowed to mix enhancement in a single inheritance hierarchy)
    marker[play.db.ebean.Model] className[models.user.User]</p>
  </blockquote>
  
  <p>I know I could wrap my Strings and Enums in entities, and use a @ManyToMany relationship, but the thought of it makes me shiver. Is there a bug here in Play 2.0 or Ebean (using v2.7.3)? Are there other ways I could solve my problem?</p>