Reading ResultList from @NamedQuery EJB3 in JAVA
Posted on 2009-12-30
I have a @NamedQuery which is essentially 1 select stmtnt and return 1 field from the server and i have no problem obtaining that value using the code below:
countOfBills = qry.getSingleResult();
But when I create a @NamedQuery which returns multiple rows of fields, the only feasible solution is to use
Query qry = m_BillingEntityManager.createNamedQuery("GetTaxDetails") .setParameter("bID", lBillId);
List lTaxObjects= qry.getResultList();
however I cannot do anything with this list for some reason... it throws classcastexception if i try to cast it to anything other then (Object)...
I've read that the system knows to return that particular object from which the query is being executed so i've changed it explicitly to be a list of TAX objects but then im still at the same problem...
List<Tax> lTaxObjects= qry.getResultList();
am i missing some constructor or something in my EJB class (Tax class)?
all i have there are getters/ setters/ @named querries and the fields ..