title: SpringData JPA - Provided id of the wrong type for class . Expected: class java.lang.Integer, got class java.lang.Long
body: <p>i'm facing this issue while using Spring JPA and trying to retrieve a List of objects.</p>
  
  <p>This is the class i'm trying to retrieve</p>
  
  <pre><code>@Entity
  @Table(name="OBJECTSTERMIC")
  public class TermicObject {
  
      @Id
      @Column(name="TERMICID")
      private long termicId;
  
      @MapsId
      @OneToOne(fetch = FetchType.LAZY)
      @JoinColumn(name="OBJECTID",columnDefinition="INTEGER")
      private Object object;
  
      @Column(name="CONTECA_RIF")
      private int contecaRif;
  
      @Column(name="CONTECA_VAL")
      private int contecaVal;
  
      @Column(name="TYPE")
      private String type;
  
  //getters and setters
  </code></pre>
  
  <p>The <code>Object</code> class has the primary key on MySQL stored as an Integer, indeed this is Object</p>
  
  <pre><code>@Entity
  public class Object {
  
      @Column(name="OBJECTID")
      @Id
      @JsonProperty("OBJECTID")
      private int objectId;
      ....
  </code></pre>
  
  <p>So, nowhere is set a Long...</p>
  
  <p>Now, i simply call in a service class</p>
  
  <pre><code>@Override
      public List&lt;TermicObject&gt; findAll() {
  
          return repository.findAll();
      }
  </code></pre>
  
  <p>and got this exception</p>
  
  <pre><code>org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TypeMismatchException: Provided id of the wrong type for class it.besmart.db_eipo.persistence.model.Object. Expected: class java.lang.Integer, got class java.lang.Long; nested exception is java.lang.IllegalArgumentException: org.hibernate.TypeMismatchException: Provided id of the wrong type for class it.besmart.db_eipo.persistence.model.Object. Expected: class java.lang.Integer, got class java.lang.Long
  </code></pre>
  
  <p>Where is set that Object Id should be Long?</p>