title: Hibernate : org.hibernate.PropertyAccessException: IllegalArgumentException
body: <p>I have a parent table  (MHS_USER) and associated child table (GROUP) mapped with ManyToMany relation as follows (the relevant code below)</p>
  
  <pre><code>@Entity
  @Table(name = "mhs_user")
  public class MHSUser extends implements Comparable&lt;User&gt; {
          @ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
          @JoinTable(name = "user_group_rel", joinColumns = @JoinColumn(name = "mhs_user_id"), inverseJoinColumns = @JoinColumn(name = "group_id"))
          public List&lt;Group&gt; getGroups() {
                  return groups;
          }
          public void setGroups(List&lt;Group&gt; groups) {
                  this.groups = groups;
          }
  
  }
  </code></pre>
  
  <p>In the above, mhs_user_id  is the identity column in the MHS_USER table and grp_id is the identity key in the GROUP table. USER_GROUP_REL table is the join table that holds the relation between the two. When I persist a new User instance, it works as expected (by inserting a record into the parent table as well as the child table). However, when I try updating any values to the User instance, PropertyAccessException is thrown.  Below is the selective stack trace </p>
  
  <pre>------------------------------------------------------------------------------------------
  [1/14/11 13:59:10:154 CST] 0000004b SystemErr     R Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of edu.mayo.hcdm.mhsr.businessobject.Group.id
          at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
          at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:183)
  ………………………………………………………………………………………………………………………………………………..
  ………………………………………………………………………………………………………………………………………………..
  ………………………………………………………………………………………………………………………………………………..
  ……………………………………………………………………………………………………………………………………………….. [1/14/11 13:59:10:154 CST] 0000004b SystemErr     R    ... 90 more
  [1/14/11 13:59:10:154 CST] 0000004b SystemErr     R Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
  ------------------------------------------------------------------------------------------
  </pre>
  
  <p>It get’s confusing as Hibernate throws an error that the "object is not an instance of declaring class" when searching for the group_id from the GROUP table only on updates. I found a lot of threads online about it being a hibernate bug (am using Hibernate 3.3.1). Has anyone encountered the same problem and if so, how did you end up solving it? 
  Any input is highly appreciated.</p>