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