即使我正在转换Object为 int,但会发生此异常......
实际上我的 Hibernate-JPA 方法是返回Object然后我将它转换Object成int......
这是我的休眠代码:
@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();
}
现在我将其转换Object为int:
int k = (Integer) userService.getAttendanceList(currentUser);
我正在转换Object为Integer.