Hi everybody,
When I try to execute the following code a java.lang.NullPointerException is throwed while executing
List res = q.getResultList();
public int getMax(){
Query q = em.createQuery("select new entities.MinMax(min (o.value),max(o.value)) from Values as o");
if(q == null)
return -1;
List res = q.getResultList();
MinMax result = (MinMax)res.get(0);
return result.getMaxv();
}
The exception is throwed only if the table mapped by entity Values is empty.
How I can avoid it? There is another way to cast the result of the EJBQL to entities.MinMax witch sets default values to MinMax fields if the table is empty? I use Toplink.
Thanks!
Edited by: Santinizer on Feb 20, 2008 5:57 AM