Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA: how do you get/print the JPQL query string behind a (typed) query after parameters have been set?

How do you get/print the JPQL query string behind a (typed) query, that is after parameters have been set? (e.g. for debugging purposes)

A simple toString() doesn't seem to do the trick...

Thanks

like image 927
Kawu Avatar asked Oct 10 '11 12:10

Kawu


1 Answers

There is no such thing as "the final JPQL that ultimately gets translated to the final SQL". How a JPA implementation generates the SQL is down to it, and parameters in general will never be substituted into any String. SQL is generated from expression trees etc not a String. If you want param values inserting in then do it yourself since it only makes sense to you

like image 58
DataNucleus Avatar answered Sep 28 '22 02:09

DataNucleus