title: Failed to convert property value of type 'java.lang.Integer' to required type
body: <p>I'm setting a many to many relationship, my join table JoinTable has a composite Pk with two keys, the problem is that when I try to persist my entity hibernate keeps saying that he can't convert <code>java.lang.Long</code> to the required type (<code>User</code> or <code>Weeks</code>)</p>
  
  <p>I've tried changing the attributes to java primitives (long and int, respectively) but then hibernate can't set this values to the target type (an object).</p>
  
  <p>I've mapped the relation like this:</p>
  
  <p><strong>User.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Column(name="id", nullable=false)  
  @Id 
  @GeneratedValue(generator="USER_ID_GENERATOR")  
  @org.hibernate.annotations.GenericGenerator(name="USER_ID_GENERATOR", strategy="native")    
  private long id;
  
  @OneToMany(mappedBy="user", targetEntity=com.ti.project.Model.JoinTable.class)  @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK}) 
  @org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)  
  private java.util.Set jointable = new java.util.HashSet();
  </code></pre>
  
  <p><strong>Weeks.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Column(name="week_id", nullable=false) 
  @Id 
  @GeneratedValue(generator="WEEK_ID_GENERATOR")  
  @org.hibernate.annotations.GenericGenerator(name="WEEK_ID_GENERATOR", strategy="native")    
  private int week_id;
  
  @OneToMany(mappedBy="week",targetEntity=com.ti.project.Model.JoinTable.class)   
  @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK}) 
  @org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)  
  private java.util.Set jointable = new java.util.HashSet();
  </code></pre>
  
  <p><strong>JoinTable.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@PrimaryKeyJoinColumn       
  @ManyToOne(targetEntity=com.ti.project.Model.User.class, fetch=FetchType.LAZY)  
  @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})    
  @JoinColumns(value={ @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) }, foreignKey=@ForeignKey(name="FKuser_su465470"))  
  private com.ti.project.Model.User user;
  
  @Column(name="user_id", nullable=false, insertable=false, updatable=false)  
  @Id     
  @org.hibernate.annotations.GenericGenerator(name="USERID_GENERATOR", strategy="foreign", parameters=@org.hibernate.annotations.Parameter(name="property", value="user"))    
  private long userId;
  
  @PrimaryKeyJoinColumn   
  @ManyToOne(targetEntity=com.ti.project.Model.Weeks.class, fetch=FetchType.LAZY) 
  @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})    
  @JoinColumns(value={ @JoinColumn(name="week_id", referencedColumnName="week_id", nullable=false) }, foreignKey=@ForeignKey(name="FKweek_su338979")) 
  private com.ti.project.Model.Weeks week;
  
  @Column(name="week_id", nullable=false, insertable=false, updatable=false)  
  @Id 
  @GeneratedValue(generator="WEEKID_GENERATOR")   
  @org.hibernate.annotations.GenericGenerator(name="WEEKID_GENERATOR", strategy="foreign", parameters=@org.hibernate.annotations.Parameter(name="property", value="week"))    
  private int weekId;
  </code></pre>
  
  <p><strong>JoinTablePK.java</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@ManyToOne(targetEntity=com.ti.project.Model.User.class, fetch=FetchType.LAZY)  
  @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})    
  @JoinColumns(value={ @JoinColumn(name="user_id", referencedColumnName="id", nullable=false) }, foreignKey=@ForeignKey(name="FKuser_su465470"))  
  private com.ti.project.Model.User user;
  
  @ManyToOne(targetEntity=com.ti.project.Model.Weeks.class, fetch=FetchType.LAZY) 
  @org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})    
  @JoinColumns(value={ @JoinColumn(name="week_id", referencedColumnName="week_id", nullable=false) }, foreignKey=@ForeignKey(name="FKweek_su338979")) 
  private com.ti.project.Model.Weeks week;
  </code></pre>
  
  <p>And this is the exception generated:</p>
  
  <pre class="lang-java prettyprint-override"><code>Failed to convert property value of type 'java.lang.Integer' to required type 'com.ti.project.Model.Weeks' for property 'week'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.Integer' to required type 'com.ti.project.Model.Weeks' for property 'week': no matching editors or conversion strategy found
  </code></pre>
  
  <p>I expect to persist this <code>JoinTable</code> entity, but this exception is making me crazy Any idea?</p>