开发者

Hibernate executed queries and testing

Is there a way to find out what queries are executed with hibernate?

I would like to write a performance test to ensure only a specific query and amount are run.

Update: Ju开发者_运维技巧st a clarification, i would like to programatically find out how many queries are run, not just via visual-manual inspection, so it would easily testable.


Enable Hibernate statistics and use SessionFactory#getStatistics() to retrieve a Statistics and access the metrics related to queries.

See getQueries(), getQueryStatistics(String), QueryStatistics and the other methods.

References

  • Hibernate Core Reference Guide
    • 3.4.6. Hibernate statistics
    • 20.6. Monitoring performance


hibernate.show_sql =true would show all the sqls executed.

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜