Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320294 - Lessen type restriction on query parameters
Summary: Lessen type restriction on query parameters
Status: CLOSED WONTFIX
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard: submitted_patch
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-19 12:05 EDT by Blaise Doughan CLA
Modified: 2022-06-09 10:34 EDT (History)
2 users (show)

See Also:


Attachments
JPA - Fix (1.53 KB, patch)
2010-07-19 12:07 EDT, Blaise Doughan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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