Tuesday, August 27, 2013

java.util.ConcurrentModificationException

 for(DbtDebtVchrSum com:this.companySummary)
        {
            if(com.getTotalDebit().compareTo(com.getPayment())==0)
              rmvList.add(com);
        }
       
       
        for(DbtDebtVchrSum com:rmvList)
        {
            this.companySummary.remove(com);
        }

Tuesday, August 13, 2013

JPA Custom Query

    Query q1 = em.createQuery("SELECT e.name, e.salary FROM Employee e");
    List<Object[]> result1 = q1.getResultList();
    for (Object[] resultElement : result1) {
        String name = (String)resultElement[0];
        Double salary = (Double)resultElement[1];
        ...
    }

    Query q2 = em.createQuery("SELECT e.name, e.salary, e.department FROM Employee e");
    List<Object[]> result2 = q2.getResultList();
    for (Object[] resultElement : result2) {
        String name = (String)resultElement[0];
        Double salary = (Double)resultElement[1];
        Department dept = (Department)resultElement[2];
        ...
    }

    Query q3 = em.createQuery("SELECT COUNT(e), SUM(e.salary) FROM Employee e");
    Object[] result3 = (Object[])q3.getSingleResult();
    Long count = (Long)result3[0];
    Double sum = (Double)result3[1];