Issue Details (XML | Word | Printable)

Key: NUCJPA-240
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Unassigned
Reporter: Matthew T. Adams
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus API JPA

Separate namespaces of type aliases and named parameters

Created: 11/Jun/13 03:47 PM   Updated: 11/Jun/13 05:31 PM
Component/s: None
Affects Version/s: 3.2.2, 3.2.3
Fix Version/s: None

Environment:
From mvn dependency:tree
[INFO] +- org.datanucleus:datanucleus-accessplatform-jpa-rdbms:pom:3.2.2:compile
[INFO] | +- javax.jdo:jdo-api:jar:3.0:compile
[INFO] | | \- javax.transaction:transaction-api:jar:1.1:compile
[INFO] | +- org.datanucleus:datanucleus-core:jar:3.2.3:compile
[INFO] | +- org.datanucleus:datanucleus-api-jpa:jar:3.2.2:compile
[INFO] | +- org.datanucleus:datanucleus-jpa-query:jar:3.0.2:compile
[INFO] | \- org.datanucleus:datanucleus-rdbms:jar:3.2.2:compile

Forum Thread URL: http://www.datanucleus.org/servlet/forum/viewthread_thread,7538
Datastore: Apache Derby
Severity: Test/Acceptance


 Description  « Hide
The query "SELECT u FROM User u WHERE LOWER(u.username) = :u" causes DataNucleus to throw:

java.lang.IllegalArgumentException: Parameter u needs to be assignable from app.domain.model.User yet the value is of type java.lang.String
at org.datanucleus.store.query.Query.applyImplicitParameterValueToCompilation(Query.java:876)
at org.datanucleus.store.query.AbstractJPQLQuery.compileInternal(AbstractJPQLQuery.java:311)
at org.datanucleus.store.rdbms.query.JPQLQuery.compileInternal(JPQLQuery.java:213)
at org.datanucleus.store.query.Query.setImplicitParameter(Query.java:811)
at org.datanucleus.store.rdbms.query.JPQLQuery.setImplicitParameter(JPQLQuery.java:145)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:438)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:58)

This suggests that DN is combining the namespaces of type aliases and named parameters, which I think should be separate.

Test case will follow after I get issue number.

Matthew T. Adams added a comment - 11/Jun/13 04:21 PM - edited
Reproducible test case on branch NUCJPA-240 at matthewadams/test-jpa (https://github.com/matthewadams/test-jpa/tree/NUCJPA-240)

Andy Jefferson added a comment - 11/Jun/13 05:24 PM
In Java you wouldn't be able to have one variable called "u" of type "mydomain.User" and another variable called "u" of type "String", consequently that's why we don't allow it. Obviously if you want such a thing a patch is the way to contribute it.

Andy Jefferson made changes - 11/Jun/13 05:24 PM
Field Original Value New Value
Priority Major [ 3 ] Minor [ 4 ]
Matthew T. Adams added a comment - 11/Jun/13 05:31 PM
Ah, yes, but JPQL is not even attempting to be Java. As such, the namespaces of type aliases & named parameters should still be separate.

I might agree with you if we were talking JDOQL... :)

Simple workaround. I didn't realize that I took the default priority of "Major". I agree that it's minor.