Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink translating # to ? in native query(EclipseLink translating # to ? in native query)
EclipseLink translating # to ? in native query [message #653379] Wed, 09 February 2011 15:23 Go to next message
No real name is currently offline No real nameFriend
Messages: 4
Registered: November 2010
Junior Member
We have column in a table which has # at the end. Ex; CAS#

I am writing native query with intersect and Minus. I have this column in my select. When I run the query, CAS# is translated to CAS?. Which is looking for paramaters.


I tried query.setHint(QueryHints.BIND_PARAMETERS, HintValues.FALSE); . But it replaces # to NULL.

Is there anyway I can let EclipseLink not to translate this. Is there anything I can do.

Please help
Re: EclipseLink translating # to ? in native query [message #653393 is a reply to message #653379] Wed, 09 February 2011 16:00 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Hello,

EclipseLink must search the SQL string to look for parameters regardless of binding being used or not, and uses the '#' character for parameters by default. The character used can be changed using the QueryHints.PARAMETER_DELIMITER to specify a new character to use instead ie:
query.setHint("eclipselink.jdbc.parameter-delimiter", "@");

Best Regards,
Chris
Re: EclipseLink translating # to ? in native query [message #653455 is a reply to message #653393] Wed, 09 February 2011 20:13 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 4
Registered: November 2010
Junior Member
Thanks for the reply Chris, But I have tried using QueryHints.PARAMETER_DELIMITER . But it gives error saying PARAMETER_DELIMITER is not found in QueryHints.

[Updated on: Wed, 09 February 2011 20:14]

Report message to a moderator

Re: EclipseLink translating # to ? in native query [message #653470 is a reply to message #653455] Wed, 09 February 2011 20:49 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1039
Registered: July 2009
Senior Member
Hello,

Which version are you using? This was added for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=325167
so you could try the workaround of using
JpaHelper.getDatabaseQuery(aQuery).setIsUserDefined(false);
if you cannot move to a version that has the fix.

Best Regards,
Chris
Re: EclipseLink translating # to ? in native query [message #653471 is a reply to message #653470] Wed, 09 February 2011 21:00 Go to previous message
No real name is currently offline No real nameFriend
Messages: 4
Registered: November 2010
Junior Member
Thank you Chris. The workaround worked for me.

We are using Eclipslink 1.0 with JPA2.0 Preview which comes with Jdev 11.1.1.3.0. We are using Weblogic which doesn't support JPA2.0 yet (The new realese this month supports but haven't moved to that). So basically we are using eclipse.persistence_1.0.0.0_2-0.

Thank you so much for your help.
Previous Topic:NullPointerException in eclipselink 2.1.2 code : JoinedAttributeManager.java
Next Topic:DriverManager connect failed
Goto Forum:
  


Current Time: Thu Nov 27 11:12:01 GMT 2014

Powered by FUDForum. Page generated in 0.01757 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software