It's not a secret anymore!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes namedQuery error : node to traverse cannot be null! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "namedQuery error : node to traverse cannot be null!" Watch "namedQuery error : node to traverse cannot be null!" New topic
Author

namedQuery error : node to traverse cannot be null!

Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

hi,
I am trying to execute a namedQuery from a JUnit test class :



Here is the entity bean code :


I have this error :


It works well if i call this named query from a session bean.
Is this a problem of persistence context ?
Please enlighten me. Thanks.
[ September 02, 2008: Message edited by: Celinio Fernandes ]

SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
Sergio Tridente
Ranch Hand

Joined: Mar 22, 2007
Posts: 329



Shouldn't it be "select p from People p where p.country = :theCountry"? Or "select c from Client c where c.country = :theCountry"?

Could you post both entities' (Person and Client) complete definition?
[ September 02, 2008: Message edited by: Sergio Tridente ]

SCJP 1.4 (88%) - SCJP 5.0 Upgrade (93%) - SCWCD 1.4 (97%) - SCBCD 5.0 (98%)
Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

hey Sergio, good point, I made a wrong copy-paste.
I changed it in the initial post. There is only one entity : People.
Do you know where the problem is ?
krishna bulusu
Ranch Hand

Joined: Aug 28, 2006
Posts: 185
Hey,

You should following method in EntityManager for named queries:

Hope this helps!!


Thanks&Regards, Krishna.
SCJP1.4, SCWCD1.4, SCBCD 5.0
Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

thanks, that was it :
createNamedQuery(...)
A simple mistake, thanks a lot again !
Hooman Peiro Sajjad
Greenhorn

Joined: Aug 19, 2009
Posts: 1
Celinio Fernandes wrote:thanks, that was it :
createNamedQuery(...)
A simple mistake, thanks a lot again !


Hey guys, it's em.getNamedQuery(aString), isn't it?


Hooman Perio Sajjad <peirosajad@jdnasir.ac.ir>
 
GeeCON Prague 2014
 
subject: namedQuery error : node to traverse cannot be null!