0

how to show the full string of a query using SQLQuery. I tried to use getQueryString() but it doesn't show the parameter values in the returned string.

any idea how to display the full query that will be executed on the MySQL DB server?

Query query = session.createSQLQuery(
"select * from stock s where s.stock_code = :stockCode")
.addEntity(Stock.class)
.setParameter("stockCode", "7277");

query.getQueryString(); 
// this will return "select * from stock s where s.stock_code = :stockCode" 
// and I need  "select * from stock s where s.stock_code = 7277"
Java Fan
  • 47
  • 1
  • 5

1 Answers1

0

You can enable logging of the following categories (using a log4j.properties file here):

 log4j.logger.org.hibernate.SQL=DEBUG
 log4j.logger.org.hibernate.type=TRACE

Refer this :

Community
  • 1
  • 1
Tejas
  • 1,361
  • 1
  • 13
  • 26