marți, 20 iunie 2023

Debugging (and understanding) Hibernate

Put a breakpoint inside each method of org.hibernate.EmptyInterceptor and hit Debug. 

UPDATE: If we will inspect any Hibernate operation, or more technically chain of Hibernate method calls, we will always find a e method of Interceptor interface (implemented by EmptyInterceptor). In this way placing a breakpoint in EmptyInterceptor methods and inspecting breakpoint neighborhoods we will favor finding the solution.

Also if you want to know which part of your code generated a specific query, then put a conditional break point (e.g. statement.contains("from <my_table>")) inside SqlStatementLogger.logStatement(String statement) method.

Also if you want to know from which cache was the entity loaded

- set log level trace for org.hibernate.event.internal.DefaultLoadEventListener

- set log level debug for org.hibernate.SQL

Niciun comentariu:

Trimiteți un comentariu