Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » SQL String from JPQL Query(How to get a complete SQL String from JPQL Query)
SQL String from JPQL Query [message #685893] Mon, 20 June 2011 14:34 Go to next message
Alberto  is currently offline Alberto Friend
Messages: 7
Registered: February 2011
Junior Member
I've a JPQLquery and I want to get the sql String..
Now I'm doing in this way:

EJBQueryImpl qi = (EJBQueryImpl)jpqlQuery;
String sqlQueryString = qi.getDatabaseQuery().getSQLString();

The problem is that in the sqlQueryString the constant are replaced with ?

I've tried to get the values of the parameters navigating the expressions trees (getSelectionCriteria() and getHavingCriteria()) and I get it.. the problem is that in this way I lose the type (I can't get the difference between Strings or int..)

Do any one ever have a problem like this one?

[Updated on: Mon, 20 June 2011 15:11]

Report message to a moderator

Re: SQL String from JPQL Query [message #686068 is a reply to message #685893] Tue, 21 June 2011 15:09 Go to previous messageGo to next message
Sven Klemm is currently offline Sven KlemmFriend
Messages: 9
Registered: June 2011
Junior Member
If you needed in runtime - i don't know yet...
... but in the log (tested with logging mode "ALL") you'll get the bindings:
[EL Fine]: 2011-06-21 17:06:00.434--ClientSession(305967)--Connection(18388366)--Thread(Thread[main,5,main])--SELECT col1, col2 FROM mytable WHERE (col1 = ?)
bind => [1]

<property name="eclipselink.logging.file" value="output.log"/>
<!--property name="eclipselink.logging.level" value="SEVERE"/ -->
<property name="eclipselink.logging.level" value="ALL"/>

So stmt = SELECT col1, col2 FROM mytable WHERE (col1 = 1)


[Updated on: Tue, 21 June 2011 15:11]

Report message to a moderator

Re: SQL String from JPQL Query [message #687947 is a reply to message #686068] Thu, 23 June 2011 14:57 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member


James : Wiki : Book : Blog : Twitter
Previous Topic:@UnionPartitioning does not seem to be using the correct connection pool
Next Topic:(no subject)
Goto Forum:

Current Time: Mon May 10 18:00:05 GMT 2021

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

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

Back to the top