문제

Is there any way I can check, how is the query being framed or what values are being passed ? I want to check for this query :

String hql = "from Scheduled where stime <= current_time()"; // QUERY

List list = session.createQuery(hql).list();

I want to know what value of current_time() is being sent ?

도움이 되었습니까?

해결책

current_time() is not replaced with a specific time in hibernate - it is passed as part of the SQL to the database and is evaluated there. Therefore, current_time() will be whatever the current time is on the database server at the time the statement is executed.

다른 팁

You can enable Hibernate logging and these two params should be of help to you:

  • org.hibernate.SQL - Log all SQL DML statements as they are executed
  • org.hibernate.type - Log all JDBC parameters

If your underlying database is SQL Server, then another option is SQL Profiler.

Here are entries from log4j.properties which works for me to print hibernate queries and parameters.

log4j.logger.org.hibernate=DEBUG, stdout
log4j.logger.org.hibernate.SQL=DEBUG
log4j.logger.org.hibernate.type=TRACE,stdout
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top