title: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer in java 1.6
body: <p>Even I'm casting <code>Object</code> into int, but this exception occur...</p>
  
  <p>Actually my Hibernate-JPA method was return <code>Object</code> then I'm converting that <code>Object</code> into <code>int</code>...</p>
  
  <p>Here is my Hibernate code:</p>
  
  <pre><code>@Transactional
  public Object getAttendanceList(User user){
  
      Query query = entityManager.createQuery("select Count(ad) from AttendanceDemo ad inner join ad.attendee at  where at.user=:user",
              Long.class);
      query.setParameter("user", user);
      return query.getSingleResult();
  }
  </code></pre>
  
  <p>Now I'm converting this <code>Object</code> as <code>int</code>:</p>
  
  <pre><code>int k = (Integer) userService.getAttendanceList(currentUser);
  </code></pre>
  
  <p>I'm converting <code>Object</code> to <code>Integer</code>.</p>