Total Pageviews

2009/01/14

NamedQuery of name: jobDutyJobTitle.findByJobDuty not found.

As I used JPA as my persistence tier implementation. I declared a named query in my entity class:










And I called this name query in my DAO class:












But as I ran my web application, it got this kind of error message (no matter the name of query or the sql statement is corrent):

java.lang.IllegalArgumentException: NamedQuery of name: jobDutyJobTitle.findByJobDuty not found. 
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getDatabaseQuery(EJBQueryImpl.java:422) 
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.setAsSQLReadQuery(EJBQueryImpl.java:136) 
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:464) 
    at com.htc.hr.dao.JobDutyJobTitleDAO.findByJobDuty(JobDutyJobTitleDAO.java:41) 
    at com.htc.hr.controller.JobDutyController.showJobDutyJobTitle(JobDutyController.java:47)

The root cause is: I forgot to add this enity class declaration into persistence.xml

4 comments:

Unknown said...

Ran into the same issue... Your post was very straightforward and useful! Thanks!

Unknown said...

Precise.Thankyou!
The class (or classes) should be specified outside the properties tag.

Marcelo Honorato said...

Muito bom seu Post. Resolveu meu problema de imediato!

Sadaf said...

Brilliant! Exactly what I needed to know.. Thanks!