title: Persisting LinkedList in Hibernate
body: <p>I am trying to persist a Class with a LinkedList Attribute but can't seem to get it right. Here is my code and my mapping:</p>
  
  <pre><code> import java.util.LinkedList;
   public class Stuff implements java.io.Serializable {
      private long id;
  private LinkedList&lt;Image&gt; images;
  
  
  public Stuff() {
  }
  
  
  public Stuff(long Id) {
      id = Id;
  }
  
  public long getId() {
      return id;
  }
  
  public void setId(long mealId) {
      id = mealId;
  }
  
  
  public LinkedList&lt;Image&gt; getNumberImages(int number) {
      assert (number &gt;= 0);
      return (LinkedList&lt;Image&gt;) images.subList(0, number) ;
  }
  
  public LinkedList&lt;Image&gt; getImages() {
      return images;
  }
      public LinkedList&lt;Image&gt; setImages(LinkedList&lt;Image&gt; images) {
      this.images = images;
  }
  
  
  public void addImage(Image image) {
      if (!images.contains(image)) {
          images.add(image);
      }
  }
  </code></pre>
  
  <p>Hibernate mapping:</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
      &lt;class name="data.Stuff" table="Stuff"&gt;
          &lt;id name="id" type="long" access="field"&gt;
              &lt;column name="ID" /&gt;
              &lt;generator class="assigned" /&gt;
          &lt;/id&gt;
          &lt;list name="images" inverse="false" table="IMAGE" lazy="true" access="field"&gt;
              &lt;key&gt;
                  &lt;column name="ID" /&gt;
              &lt;/key&gt;
              &lt;list-index&gt;&lt;/list-index&gt;
              &lt;one-to-many class="data.Image" /&gt;
          &lt;/list&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>It seems I can persist objects of the Class Stuff like this but when I try to recover them the following error occurres :</p>
  
  <pre><code>Hibernate: select stuff0_.ID as ID0_, stuff0_.NAME as NAME0_, meal0_.GROUPING as GROUPING0_ from MEAL meal0_
  org.hibernate.PropertyAccessException: could not set a field value by reflection setter of data.Meal.images
  </code></pre>