title: Can not set java.lang.Long field com.jobs.spring.domain.Employee.id to java.lang.Long
body: <p>I am using Java 8 with JPA2/Hibernate5 and MySQL.</p>
  
  <p>I am getting the following <strong>error</strong>, any help is appreciated.</p>
  
  <pre><code>PropertyAccessException: Error accessing field [private java.lang.Long com.jobs.spring.domain.Employee.id] by reflection for persistent property [com.jobs.spring.domain.Employee#id] : 31
  
  IllegalArgumentException: Can not set java.lang.Long field com.jobs.spring.domain.Employee.id to java.lang.Long
  </code></pre>
  
  <p><strong>tables</strong></p>
  
  <pre><code>+--------+    +----------------+    +----------+ 
  | Rating |    | Rating_Employee|    | Employee |
  +--------+    +----------------+    +----------+ 
  | ID     |    | RAT_ID         |    | ID       |
  | REVIEW |    | EMP_ID         |    +----------+ 
  +--------+    +----------------+    
  </code></pre>
  
  <p><strong>code</strong></p>
  
  <pre><code>@Override
  public List&lt;Rating&gt; findAll(int firstResult, int maxResults, Long employeeId) {
      final EntityManagerFactory entityManagerFactory = entityManager.getEntityManagerFactory();
      final CriteriaBuilder criteriaBuilder = entityManagerFactory.getCriteriaBuilder();
      CriteriaQuery&lt;Rating&gt; criteria = criteriaBuilder.createQuery(Rating.class);
      Root&lt;Rating&gt; root = criteria.from(Rating.class);
      ParameterExpression&lt;Long&gt; param = criteriaBuilder.parameter(Long.class);
      criteria.select(root).where(criteriaBuilder.equal(root.get("employee"), param));
      TypedQuery&lt;Rating&gt; queryRating = entityManager.createQuery(criteria);
      queryRating.setParameter(param, employeeId);
      List&lt;Rating&gt; results = queryRating.getResultList();
  
      return results;
  }
  </code></pre>
  
  <p><strong>model</strong> (Rating.java)</p>
  
  <pre><code>@OneToOne(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
  @JoinTable
  (
      name="rating_employee",
      joinColumns={ @JoinColumn(name="RAT_ID", referencedColumnName="ID") },
      inverseJoinColumns={ @JoinColumn(name="EMP_ID", referencedColumnName="ID") }
  )
  private Employee employee;
  </code></pre>
  
  <p><strong>model</strong> (Employee.java)</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;
  </code></pre>