SQL String from JPQL Query [message #685893] |
Mon, 20 June 2011 14:34 |
Alberto 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 |
Sven Klemm Messages: 11 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]
----------------------------------------------------------
persistence.xml:
----------------------------------------------------------
<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)
sk
[Updated on: Tue, 21 June 2011 15:11] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03582 seconds