ebean debug sql

1,636 views
Skip to first unread message

Bence

unread,
Jul 31, 2012, 12:06:00 PM7/31/12
to play-fr...@googlegroups.com
I tried both
ebean.debug.sql=true 
and
ebean.default.debug.sql=true 

Caused by: com.typesafe.config.ConfigException$BadPath: path parameter: Invalid path ' - could not find datasource for
default.debug.sql': Token not allowed in path expression: '-' (you can double-quote this token if you really want it her
)

How could I check the generated sql of ebean?

K.Alkassoum

unread,
Jul 31, 2012, 9:56:36 PM7/31/12
to play-fr...@googlegroups.com
if you have set a queryString, by code the simple way is:

final Query<? extends Model> query = Ebean.createQuery(clazz, queryString).setReadOnly(true);
try {
query.findList();// executes the the query and gets back the getGeneratedSql
} catch (Exception e) {
e.printStackTrace();
}
String generatedSql = query.getGeneratedSql() ;
Logger.debug(generatedSql);

Bence

unread,
Aug 1, 2012, 2:56:06 AM8/1/12
to play-fr...@googlegroups.com
No, I'm using Finder, but I could figure out how to modify it:

            final Query<User> query = User.find.where().ieq("name", username).query();
            user = query.findUnique();
            Logger.debug(query.getGeneratedSql());
 
It's not nice but working, thanks.

But: is there a simpler way? Without code modification... I.e.: with play configuration?

Kevin Bosman

unread,
Aug 1, 2012, 3:15:11 AM8/1/12
to play-fr...@googlegroups.com

Add the following to your application.conf:

db.default.logStatements= true
logger.com.jolbox=DEBUG

Bence Takács

unread,
Aug 1, 2012, 3:28:20 AM8/1/12
to play-fr...@googlegroups.com
Thanks, it's working.

WeAreTheSmallAxe

unread,
Sep 4, 2012, 6:20:52 PM9/4/12
to play-fr...@googlegroups.com
When I use getGeneratedSql() I don't see the parameters used in the sql string, just the sql query with question marks where the parameters should go.  Is there a way to see the params also?


Bence Takács

unread,
Sep 4, 2012, 7:19:12 PM9/4/12
to play-fr...@googlegroups.com
I'm afraid: no. Just the manual logging of parameters before, so you can merge them with the query in mind :-)

This is a kind of standard: check Hinernate and others. I think this is because the "thing" in the logs is a prepared statement, not the running query itself.



On Wed, Sep 5, 2012 at 12:20 AM, WeAreTheSmallAxe <jasonm...@gmail.com> wrote:
When I use getGeneratedSql() I don't see the parameters used in the sql string, just the sql query with question marks where the parameters should go.  Is there a way to see the params also?



--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/QyZwPQRQa1EJ.

To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Reply all
Reply to author
Forward
0 new messages