Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Named Query not found(Named query defined using deploy.xml not found by EntityManager)
Named Query not found [message #903502] Thu, 23 August 2012 21:45 Go to next message
Miguel Missing name is currently offline Miguel Missing name
Messages: 9
Registered: September 2010
Junior Member
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 #904480 is a reply to message #903502] Tue, 28 August 2012 09:55 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris Delahunt
Messages: 995
Registered: July 2009
Senior Member
Is the workbench creating a JPA project, persistence.xml and entities, or is it a native EclipseLink sessions.xml? Basically, what is the deploy.xml file, and how are you setting up the EntityManager and persistence.xml for using the session in JPA?
Re: Named Query not found [message #905003 is a reply to message #904480] Wed, 29 August 2012 10:42 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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"


James : Wiki : Book : Blog : Twitter
Previous Topic:Thread hang in ConcurrencyManager.acquire()
Next Topic:Dynamic EclipseLink JPA Clarification
Goto Forum:
  


Current Time: Mon Apr 21 08:54:57 EDT 2014

Powered by FUDForum. Page generated in 0.02201 seconds