Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Logging each actual *real* SQL query

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!

On Sat, Sep 11, 2010 at 11:52 AM, douglas clarke <douglas.clarke@xxxxxxxxxx> wrote:


Torbjorn,

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.

Doug



On 10/09/2010 12:30 PM, Frank Schwarz wrote:
It looks like that there is no simple solution for getting the 'real' SQL
statements. Even the EL testsuite only captures the SQL-logging (see
org.eclipse.persistence.testing.framework.QuerySQLTracker,
https://fisheye2.atlassian.com/browse/eclipselink/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/framework/QuerySQLTracker.java?r=HEAD).

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

Hope someone can help... Thanks!

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top