How do I show SQL with Play Framework?
Asked Answered
P

2

27

I have a Play app that uses a database, and for debugging purposes I want to show the SQL that JPA uses. How can I do this?

Platon answered 12/1, 2011 at 19:2 Comment(0)
P
32

In application.conf, you can turn showing SQL on uncommenting jpa.debugSQL=true. This will give you the prepared statement queries with question marks in them. Also, Play uses Hibernate, so you can also use Hibernate properties. These can be written in application.conf directly or in a separate hibernate.properties file residing in the conf folder of your Play application.

Platon answered 12/1, 2011 at 19:10 Comment(1)
To show Hibernate code hibernate.show_sql=true If you want to see it nicely formatted add hibernate.format_sql=trueDyanna
B
6

maybe this could also help

http://www.mkyong.com/hibernate/how-to-display-hibernate-sql-parameter-values-log4j/

it allows you so also see the sql binding parameters values...

Body answered 15/9, 2011 at 18:27 Comment(1)
Thanks this helped me a lot. Perhaps you should include the relevant parts in your answer in case the site every goes down. I'd also recommend just using log4j.logger.org.hibernate=WARN and log4j.logger.org.hibernate.type.descriptor.sql.BasicBinder=trace to avoid a lot of log spam and print the SQL bindings only.Serinaserine

© 2022 - 2024 — McMap. All rights reserved.