jpa - Can I make Hibernate label the SQL it produces with query names? -
when analyzing slow query reports database bit tricky associate sql java code issues them.
is possible configure hibernate attach label (as comment) sql issues? ideally, jpa namedqueries query name, dynamically constructed queries label can tell criteriabuilder use.
you can attach comment query through criteria analyzing queries, if understood correctly.
setcomment(string comment) : add comment generated sql.
parameters:comment - human-readable string
returns:this (for method chaining)
for other cases, not using criteria api, can add comment hint query.
sethint(string hintname, object value) : set query property or hint. hints elements may used specify query properties , hints. properties defined specification must observed provider. vendor-specific hints that not recognized provider must silently ignored. portable applications should not rely on standard timeout hint. depending on database in use , locking mechanisms used provider, hint may or may not observed.
[emphasis mine]
depending on implementation can add hint query, can refer here hibernate. also, there property available org.hibernate.comment
can used set comment hint.
Comments
Post a Comment