Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

getResultList() throws java.lang.NullPointerException

843830Feb 20 2008 — edited Mar 11 2008
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 8 2008
Added on Feb 20 2008
5 comments
5,279 views