How to find the source of an SQL query generated by Hibernate

Introduction In this article, we are going to see how we can find the source of an SQL query generated by Hibernate. Knowing where a given SQL query originates from is very useful when trying to investigate performance issues caused by either long-running queries or queries that are executed excessively (e.g., N+1 query issues).