I've got List dynamics. And I want to get max result using Collections. This is my code:
List dynamics=spyPathService.getDynamics();
Long max=((Long)Collections.max(dynamics)).longValue();
This is my getDynamics:
public List getDynamics() {
Session session = null;
session = this.sessionFactory.getCurrentSession();
Query query = session
.createSQLQuery("SELECT COUNT(*) FROM SpyPath WHERE DATE(time)>=DATE_SUB(CURDATE(),INTERVAL 6 DAY) GROUP BY DATE(time) ORDER BY time;");
List result = query.list();
return result;
}
Now I'm getting java.math.BigInteger cannot be cast to java.lang.Long. What's wrong?
解決方案
Your error might be in this line:
List result = query.list();
where query.list() is returning a BigInteger List instead of Long list. Try to change it to.
List result = query.list();