JPA:在设置参数后,如何获取/打印(打字)查询后面的JPQL查询字符串? [英] JPA: how do you get/print the JPQL query string behind a (typed) query after parameters have been set?
问题描述
如何获取/打印(打字)查询后面的JPQL查询字符串,也就是参数设置后的? (例如用于调试目的)
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)
一个简单的 toString()
似乎没有办法
A simple toString()
doesn't seem to do the trick...
谢谢
推荐答案
没有这样的事情最终将JPQL转化为最终的SQL。 JPA实现如何生成SQL是至关重要的,通常参数将永远不会被替换为任何字符串。 SQL从表达式tree而不是String生成。如果你想要插入参数值,那么你自己就这样做了,因为你只是有意义的
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
这篇关于JPA:在设置参数后,如何获取/打印(打字)查询后面的JPQL查询字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!