Log query with parameters

900 views
Skip to first unread message

Marlon Patrick

unread,
Feb 2, 2014, 8:40:48 PM2/2/14
to quer...@googlegroups.com
Good night,

I override some classes of QueryDSL SQL because I needed log queries with parameters. How I work with JBOSS my code stay so:

if (AbstractSQLQuery.logger.isDebugEnabled()) {
if(stmt instanceof WrappedPreparedStatementJDK6){
AbstractSQLQuery.logger.debug("query : {}", ((WrappedPreparedStatementJDK6)stmt).getUnderlyingStatement());
}else{
AbstractSQLQuery.logger.debug("query : {}", stmt);
}
}

The toString of PreparedStatement of Postgres returns the SQL with configured parameters, in another words, the exactly query that will be send to database.


This is not elegant solution, then, I propose that is created something like "LogHandler". A simple interface with method that receive a PreparedStatement and query string.

public void logStatement(PreparedStatement stmt, String queryString) throws SQLException;

And a default implementation:

public void logStatement(PreparedStatement stmt, String queryString) throws SQLException {
logger.debug("query : {}", queryString);
}


This way, case developer need a different log then creates your own implementation like my case.

timowest

unread,
Feb 3, 2014, 11:26:27 AM2/3/14
to quer...@googlegroups.com
Hi.

Could you create a ticket for it?

Br,
Timo

Marlon Patrick

unread,
Feb 5, 2014, 9:31:46 PM2/5/14
to Querydsl on behalf of timowest


2014-02-03 timowest via Querydsl <querydsl+noreply-APn2wQefkk7kI02...@googlegroups.com>:

--
You received this message because you are subscribed to a topic in the Google Groups "Querydsl" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/querydsl/07ubdhhap4M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to querydsl+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Atenciosamente,

Marlon Patrick
Reply all
Reply to author
Forward
0 new messages