Named Query not found [message #903502] |
Thu, 23 August 2012 21:45  |
Eclipse User |
|
|
|
I design all of my eclipselink 2.3 entities using Workbench. I created a named query using the workbench, but when calling createNamedQuery with my entity manager the query is not found. The query is defined in the deploy.xml descriptor, which is generated automatically by the workbench, and has very basic syntax to make troubleshooting easy. In fact, apparently no queries are present, I checked that using
((JpaEntityManager)em.getDelegate()).getSession().getQueries()
and the count is 0, there should be two named queries defined.
|
|
|
|
Re: Named Query not found [message #905003 is a reply to message #904480] |
Wed, 29 August 2012 10:42  |
Eclipse User |
|
|
|
In general you should not use the EclipseLink Mapping Workbench for JPA, it is for EclipseLink's native ORM. For JPA you should use tools such as EclipseLink JPA (Dali).
It is possible to use a sessions.xml generated by the EclipseLink Mapping Workbench, but this is more for backward compatibility for users migrating from the EclipseLink native ORM.
For the native ORM named queries are defined on the descriptor (per class), but for JPA they need to be defined on the Session, this may be why your query is not found.
There is a persistence unit property you can set to copy all of the descriptor queries to the session (you must ensure they have unique names).
"eclipselink.session.include.descriptor.queries"="true"
|
|
|
Powered by
FUDForum. Page generated in 0.28293 seconds