These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem with NamedQuery
PostPosted: Wed Nov 10, 2010 9:03 pm 
Newbie

Joined: Wed Nov 10, 2010 8:34 pm
Posts: 1
Hello everyone, i seem to be having a very weird problem with all the named queries inside my classes: I'm getting the error:

Code:
javax.ejb.EJBException: java.lang.IllegalArgumentException: Named query not found: World.getPopulation


On init, JBoss (i'm using 5.1.0.GA) says that it found both the class and the named query:

Code:
16:46:25,763 INFO  [QueryBinder] Binding Named query: World.getPopulation => SELECT COUNT(w) FROM World w WHERE w.state = :state


This is how i'm defining my "World" class:

Code:
@Entity
@Table (name="world")
@NamedQueries (value = {   
   @NamedQuery (
      name=World.GET_POPULATION,
      query="SELECT COUNT(w) FROM World w WHERE w.state = :state"
   )
})
public class World
   extends IdentifiableEntity
{
   public final static String GET_POPULATION = "World.getPopulation";
   
   ...
}


In order to call it from inside my bean i'm doing:

Code:
final EntityManager em = getEntityManager ();
      
final Query query;
query = em.createNamedQuery (World.GET_POPULATION);
query.setParameter ("state", World.ACTIVE);

return (Long) query.getSingleResult ();


Does anyone have any idea of what might be going on?

Thanks in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.