Sounds like the utility I need! That's right.. I'm going to easily execute it on a different computer. To keep the databases exactly the same. In this case, clustering and similar things is not possible as the other computer is not available on the internet, so it needs to fetch the latest SQL commands it should execute.
I had written a utility before that cloned a query, turned of
binding, and then generated SQL from the modified query without
actually using it for execution.
I'll need to dig around a bit to find it though.
I am assuming you are looking for SQL you can easily execute in a
different tool?
Doug
On 11/09/2010 6:55 AM, Torbjorn Kristoffersen wrote:
I see... I did try that, however I need parameter
binding, it's not something I'd like to compromise on. I'm
looking into my Postgres log now. Thanks!
The SQL you are seeing in the log and what the
QuerySQLTracker captures is exactly what is passed into the
JDBC prepares statements. If you would like the values
in-lined in the SQL so you can execute it elsewhere then you
will need to turn off parameter binding.
You could adopt the QuerySQLTracker for your purposes
and additionally file
an enhancement request for EclipseLink to print out
strings with quotes
('abc') and long-values with its suffix (123L) in the
"bind"-messages.
-- Frank
Torbjorn Kristoffersen wrote:
How would one go about retrieving each SQL query
that the JPA (in this
case,
EclipseLink 2) layer performs on the database?
I am interested in absolutely all the SQL queries.
I tried intercepting
them using postUpdate, postInsert and so on, but
seeing I use parameter
binding I can't get the actual native SQL query,
illustrated by the the
FINE
logging as seen in my Glassfish log:
SELECT x,y,z FROM footable WHERE My_ID = ? LIMIT ?
OFFSET ?
bind => [274087, 15, 0]|#]
I need to find out the exact query that is run on
the actual SQL server.
In
the case above, I can't be certain whether 274087 is
an int, or a string.
If it is a string, then I it would have to be
enclosed in quotes.
So what I'm looking for is the following result:
SELECT x,y,z FROM footable WHERE My_ID = '274087'
LIMIT 15 OFFSET 0