Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show JPA's SQL-Statements when using Play Framework 2

I'm developing a web application using the Play Framework with JPA/Hibernate. For debugging purposes, it would be great to see the SQL statements used by JPA. There already is another thread with the same question, but it is about Play 1 and the given solution does not work for me - it seems that jpa.debugSQL=true cannot be used in Play 2 (No Persistence provider for EntityManager named true).

Instead, I added the following to Play's application.conf:

db.default.logStatements=true
logger.org.hibernate=DEBUG

I'm not sure if I need both lines, but at least the SQL statements are logged now. But for large queries, Hibernate prints a ton of debug messages which make the already printed SQL statements disappear in my console window. I already tried to increase the buffer of the console window, but that didn't change much.

What do I have to do in order to inspect the statements in a comfortable way?

edit:

When setting logger.org.hibernate to INFO, I'm not getting any statements at all (even with db.default.logStatements=true).

like image 282
alapeno Avatar asked Mar 01 '14 11:03

alapeno


1 Answers

Try first with the config

db.default.logStatements=true
logger.org.hibernate=DEBUG

Find out which class logs the statements (for example org.hibernate.xxx.StatementLogger). Change back to INFO for org.hibernate and add a new line for the statement logger package:

logger.org.hibernate=INFO
logger.org.hibernate.xxx=DEBUG
like image 50
Gosta J Avatar answered Sep 30 '22 17:09

Gosta J