Printing out SQL statements in Play
August 6, 2013
Play!
Play
debugging
SQL
Unfortunately in Play2 there doesn’t appear to be a simple way to configure your application to print out SQL statements generated by Ebean. I believe the only way you can do it is via code.
- Create a Global class, put in your app folder.
- In your Global class, override the onStart method to configure the debugging.
public class Global extends GlobalSettings {
@Override public void onStart(Application application) { if (Play.isDev() || Play.isTest()) { Ebean.getServer(null).getAdminLogging().setDebugGeneratedSql(true); } }
}
- Enjoy the output.
select t0.id c0, t0.meeting c1, t0.date c2, t0.topic c3, t0.presenter c4 from meeting t0 where t0.meeting = ?