title: java.lang.IllegalArgumentException: Can not set int field it.besmart.models.Park.idPark to [Ljava.lang.Object;
body: <p>i'm dwelling with this problem.
  I have 3 classes</p>
  
  <p>User and Park have a ManyToMany relation, and Piano and Park have a ManyToOne relation.</p>
  
  <p>In the models, the interesting parts are
  User.java</p>
  
  <pre><code>@ManyToMany(fetch = FetchType.EAGER)
      @JoinTable(name="users_parcheggio", joinColumns = {@JoinColumn(name="user_id") }, inverseJoinColumns = {
              @JoinColumn(name="park_id") })
      private Set&lt;Park&gt; parks = new HashSet&lt;Park&gt;();
  </code></pre>
  
  <p>This is Park.java</p>
  
  <pre><code> @Entity
  @Table(name="parcheggio", catalog="SMARTPARK")
  public class Park implements Serializable{
  
      /**
       * 
       */
      private static final long serialVersionUID = -7630704706109692038L;
      @Id
      @GeneratedValue(strategy = IDENTITY)
      @Column(name = "id_park", unique = true, nullable = false)
      private  int idPark;
  
      @NotEmpty
      @Column(name="nome_park")
      private  String nomePark;
  
      @Column(name="descrizione")
      private  String descrizione;
  
      @Column(name="indirizzo")
      private String indirizzo;
  
      @Column(name="citta")
      private String citta;
  
  
      @ManyToMany(fetch = FetchType.EAGER)
      @JoinTable(name="users_parcheggio", joinColumns = {@JoinColumn(name="park_id") }, inverseJoinColumns = {
              @JoinColumn(name="user_id") })
  
      private Set&lt;User&gt; users = new HashSet&lt;User&gt;();
  
      @OneToMany(fetch = FetchType.LAZY, cascade=CascadeType.ALL, mappedBy = "park")
      private List&lt;Piano&gt; piano;
  
      public Park(){
      }
  
      public Park(int idPark, String nomePark, String descrizione, String indirizzo, String citta, Set&lt;User&gt; users, List&lt;Piano&gt; piano){
          this.idPark = idPark;
          this.nomePark = nomePark;
          this.descrizione = descrizione;
          this.indirizzo = indirizzo;
          this.citta = citta;
          this.users = users;
          this.piano = piano;
      }
  
      public List&lt;Piano&gt; getPiano() {
          return piano;
      }
  
      public void setPiano(List&lt;Piano&gt; piano) {
          this.piano = piano;
      }
  
      public  int getIdPark() {
          return idPark;
      }
  
      public  void setIdPark(int idPark) {
          this.idPark = idPark;
      }
  
  
      public  String getNomePark() {
          return nomePark;
      }
  
      public  void setNomePark(String nomePark) {
          this.nomePark = nomePark;
      }
  
  
      public  String getDescrizione() {
          return descrizione;
      }
  
      public  void setDescrizione(String descrizione) {
          this.descrizione = descrizione;
      }
  
      public String getIndirizzo() {
          return indirizzo;
      }
  
      public void setIndirizzo(String indirizzo) {
          this.indirizzo = indirizzo;
      }
  
      public String getCitta() {
          return citta;
      }
  
      public void setCitta(String citta) {
          this.citta = citta;
      }
  
      public Set&lt;User&gt; getUsers() {
          return users;
      }
  
      public void setUsers(Set&lt;User&gt; users) {
          this.users = users;
      }
  
      @Override
      public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = prime * result + idPark;
          return result;
      }
  
      @Override
      public boolean equals(Object obj) {
          if (this == obj)
              return true;
          if (obj == null)
              return false;
          if (getClass() != obj.getClass())
              return false;
          Park other = (Park) obj;
          if (idPark != other.idPark)
              return false;
          return true;
      }
  }
  </code></pre>
  
  <p>and in Piano.java</p>
  
  <pre><code>@ManyToOne
      @JoinColumn(name = "id_park")
      public Park getPark() {
          return park;
      }
  
      public void setPark(Park park) {
          this.park = park;
      }
  </code></pre>
  
  <p>When I use this 3 classes in couples (User with Park or Park with Piano) everything goes well, but now I have to get all Piano for a given User.</p>
  
  <p>In my PianoDaoImpl I have this method</p>
  
  <pre><code>public List&lt;Piano&gt; findPianoByUser() {
          Authentication auth = SecurityContextHolder.getContext().getAuthentication();
          String name = auth.getName();
          User user = userService.findBySso(name);
          int userId = user.getId();
          Query q = getSession().createQuery("from Park p join p.users u where u.id = :userId").setParameter("userId", userId);
          List&lt;Park&gt; parks = q.list();
  
          Query query = getSession().createQuery("from Piano p where p.park in :parks").setParameterList("parks", parks);
          List piani = query.list();
  
          return piani;
      }
  </code></pre>
  
  <p>The <em>q</em> query gives me correctly the parks list for the user. Then I pass this list to the second query and I got this exception</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.PropertyAccessException: could not get a field value by reflection getter of it.besmart.models.Park.idPark
  </code></pre>
  
  <p>caused by</p>
  
  <pre><code>java.lang.IllegalArgumentException: Can not set int field it.besmart.models.Park.idPark to [Ljava.lang.Object;
  </code></pre>
  
  <p>What i'm doing wrong?</p>