Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 320294

Summary: Lessen type restriction on query parameters
Product: z_Archived Reporter: Blaise Doughan <blaise.doughan>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: eclipselink.orm-inbox, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: submitted_patch
Attachments:
Description Flags
JPA - Fix none

Description Blaise Doughan CLA 2010-07-19 12:05:57 EDT
@NamedQuery(name = "findCustomerById", 
            query = "SELECT c " +
                    "FROM Customer c " +
                    "WHERE c.id = :id")

Currently if I have a query like the one above, if the id property on Customer is of type long, then EclipseLink expects me to bind a parameter of type long to the query.

It would be useful if EclipseLink could lessen this restriction and allow me to pass a value that could be converted to the appropriate type, i.e. "1".
Comment 1 Blaise Doughan CLA 2010-07-19 12:07:45 EDT
Created attachment 174642 [details]
JPA - Fix

If the parameter is not of the appropriate type, try converting it using conversion manager before throwing an exception.
Comment 2 Tom Ware CLA 2010-08-16 15:12:48 EDT
Investigating.
Comment 3 Tom Ware CLA 2010-08-17 11:25:02 EDT
Closing this bug as WONTFIX.  The attached patch has a high chance of causing us to fail the JPA TCK and additionally could cause some truncation issues when using numbers.

As we discussed, the solution to the issue you are seeing is to use the getParameter() API on JPA's Query class.  As I understand it, you will be entering a bug related to how that API is working for you, and fixing that bug should solve your problem.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:34:19 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink