Community
Participate
Working Groups
Build Identifier: JavaDoc of EntityManager says that createNamedQuery(String foo) throws an IllegalArgumentException "if a query has not been defined with the given name or …". Apparently the EclipseLink implementation does *not* throw an exception in this case. Attached you'll find a sample project triggering that call with some obviously stupid parameter. The EntityManager implementation returns a Query object that then in turn fails when being executed (by getResultList() e.g.). Tested with all release versions >= 2.0.0 as well as 2.2.0 nightly build Reproducible: Always Steps to Reproduce: 1. Setup JPA infrastucture and obtain an EntityManager backed by Eclipse 2. Call createNamedQuery("somethingObviouslyStupid"); 3. EntityManager returns a Query instance where according to the spec an exception is expected.
Created attachment 176496 [details] Testcase showing bug
Looks like we create the query wrapper and resolve it to the named query later. Should be a straight forward issue to resolve.
(In reply to comment #2) > Looks like we create the query wrapper and resolve it to the named query later. > Should be a straight forward issue to resolve. That's great news :). Just out of curiosity: doesn't that mean there's a glitch in the TCK if something (core) like this does show up during the certification?
(In reply to comment #3) > (In reply to comment #2) > > Looks like we create the query wrapper and resolve it to the named query later. > > Should be a straight forward issue to resolve. > > That's great news :). Just out of curiosity: doesn't that mean there's a glitch > in the TCK if something (core) like this does show up during the certification? Of course I wanted to state "if something (core) like this does show *not* up during the certification?". in short: I would have expected the TCK to verify something like this (expected exceptions actually popping up).
Setting target and priority see: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines for more information on the meanings of these fields.
(In reply to comment #5) > Setting target and priority see: > http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines for more > information on the meanings of these fields. Call me pedant but IMHO, incorrectly implementing the specification fulfills the attribution of "Required for Release. This fix is a requirement for the release listed in the target field.". I mean, EclipseLink is the reference documentation, so shouldn't such a violation of the contract of a very core interface considered a blocker? Regards, Ollie
Of course I meant "reference implementation"…
As with all our bugs, I would like to encourage those that feel a fix for this bug should be a high priority to vote for it. We do our best to address as many as possible of the most voted on bugs with each release.
'looks like there's a good amount of community support for fixing this bug. Changing the target to the next release.
Proposed Patch: Index: src/org/eclipse/persistence/internal/jpa/EntityManagerImpl.java =================================================================== --- src/org/eclipse/persistence/internal/jpa/EntityManagerImpl.java (revision 8004) +++ src/org/eclipse/persistence/internal/jpa/EntityManagerImpl.java (working copy) @@ -997,7 +997,9 @@ public Query createNamedQuery(String name) { try { verifyOpen(); - return new EJBQueryImpl(name, this, true); + EJBQueryImpl query = new EJBQueryImpl(name, this, true); + query.getDatabaseQueryInternal(); + return query; } catch (RuntimeException e) { setRollbackOnly(); throw e; A work-around for anyone blocked on this or using a released version of EclipseLink is to: Query query = entityManager.createNamedQuery("query-name"); JPQ 1.0: ((EJBQueryImpl<?>) query).getDatabaseQueryInternal(); JPA 2.0 query.getHints();
(In reply to comment #10) Hi Doug, what does "proposed" mean in this case? Does the patch make it into next nightly integration build? -- Ollie
I took a quick look and believe that is the correct patch. I just wanted to help out whoever ultimately fixes the bug and runs the regression suites.
Created attachment 177454 [details] Patch with test update on trunk stream This patch will be checked into the trunk stream when tests finish. The 2.1.x stream is currently closed for checkins until 2.1.1 ships. A similar patch will be included in that stream when it opens.
Fix above checked into trunk. Reviewed by Guy Pelletier Fixed RelationshipModelJUnitTestSuite.testNamedQueryDoesNotExistTest() to no longer call getResultList(). Tested with JPA LRG 2.1.x check in will occur when the stream opens.
Checked into 2.1.2
This fix targets direct usage of the EclipseLink JPA implementation. When used within an EJB 3.0/3.1 container the container provider may provide a wrapping implementation or proxy. In that case, it is up to the implementation to ensure that the named query is validated.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink