ArrayList<CustomerPayment> cp = null;
this.session = HibernateUtil.getSessionFactory().getCurrentSession();
try {
org.hibernate.Transaction tx = session.beginTransaction();
Query q = session.createQuery("select c.type, c.date, sum(c.amount) from CustomerPayment c where c.date like '%" + year + "' and c.type='Cash'");
cp = (ArrayList<CustomerPayment>)q.list();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(cp.get(0).getAmount()+"");
我在函数中有上面的代码。然而; System.out.println(cp.get(0).getAmount()+"");
我不能像这样在数组列表中打开我的元素。
如何获得对象数量中的数量?