Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View SQL generated by ORMLite on Android

I'm trying to debug a weird problem with my ORMLite query in my Android app, and it would be really handy if I could see the SQL being generated. Is there any way to output the SQL of a query as a string? It doesn't matter if it's before or after the query is executed.

For example, I have

contactQb.where().eq("enabled", true);

I'd like to see what SQL is generated for that QueryBuilder.

like image 804
Matt Rowland Avatar asked Oct 09 '13 04:10

Matt Rowland


2 Answers

Ah, I figured it out: contactQb.prepareStatementString() gives the full SQL statement.

like image 164
Matt Rowland Avatar answered Sep 25 '22 19:09

Matt Rowland


Is there any way to output the SQL of a query as a string?

As you mention logging the output of contactQb.prepareStatementString() will show you the specific query string. You can also enable ORMLite's logging to show a lot more detail. See:

http://ormlite.com/docs/android-logging

like image 31
Gray Avatar answered Sep 22 '22 19:09

Gray