Get SQL String from Hibernate query

后端 未结 5 1438
既然无缘
既然无缘 2020-12-17 17:14

I need to get the string from an Hibernate query and process it later (so I can\'t solve it with \"hibernate.show_sql\").

I have already looked at How t

5条回答
  •  既然无缘
    2020-12-17 17:55

    There is no such thing as "the full SQL string with the parameters values".

    Hibernate uses prepared statements, therefore it sends query string with ?s and parameter values to the database separately, so that the actual query is never constructed.

    Perhaps you can find a way extract parameter values from QueryImpl, but even in this case you won't be able to get a query ready for execution, because you'll need to handle escaping, conversion of parameter values to SQL literals, etc.

提交回复
热议问题