Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print the internal query in a Room database?

How to print query in Room ? Not the query written in dao but the query generated by room itself.

like image 988
Sujin Shrestha Avatar asked Apr 23 '18 09:04

Sujin Shrestha


Video Answer


1 Answers

For every DAO class you add to your project marked with @Dao Room generate a class that implement your class. Hence for operations like Insert, Update and Delete that you don't provide any query Room will create a query itself. You can see this generated classes in the following file inside your project:

{root project}/app/build/generated/source/apt

, now navigate to the package that contains DAO classes and you will see classes like IssueDao_Impl.java. Inside this class you will see queries like this:

"INSERT OR REPLACE INTO `Issue`(`id`,`displayOrder`,`pdf`,`date`,`purchasable`,`source_id`,`thumb`,`full`,`mobile`,`width`,`height`,`download_count`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";

, created with the help of the annotations you did inside your class. Cheers!

like image 183
Keivan Esbati Avatar answered Oct 12 '22 16:10

Keivan Esbati