tags:

views:

329

answers:

1

HQL queries are converted to SQL.

I would like my program to have the complete SQL string before it is sent to my database.

Can I do this?


Notes:

I can see the SQL sent to the database by setting

<property name="hibernate.show_sql">true</property>

in my cfg.xml

+2  A: 

I believe you can create a class that implements org.hibernate.Interceptor, register it with Configuration.setInterceptor(Interceptor) on startup, and then get access to the SQL through the Interceptor.onPrepareStatement(String sql) callback.

See Interceptor javadocs

nathan