Finding where why an SQL INSERT was executed with Hibernate

I am maintaining some existing Java code. There is a database table, where the program is checking for records. There is a class,, which points to the table I am interested in, subscription_retrieval. I see where the program is checking the table for records, but I want to put a breakpoint where the program normally inserts records. Assuming the code is written following normal Hibernate conventions, how do I find out where in the code records are being inserted into subscription_retrieval?

Add the breakpoint in bind(PreparedStatement st, J value, int index, WrapperOptions options) method of the org.hibernate.type.descriptor.sql.BasicBinder class navigate up the stack to see why the SQL statement is executed.

1 Like

Thanks, Vlad. It looks like the code is just including the hibernate jars, rather than the source code. Any tips on where to look in the house code for where the actual hibernate method that leads to the insert is being called? As far as I can tell, the bind( method you mentioned is not being called directly by the house code.

Try setting this property so you get a better understanding of why a certain statement was generated:

<property name="hibernate.use_sql_comments" value="true"/>
1 Like