So I’m trying to intercept calls made to a database. Right now I have a java program which listens for notifications (calls made by various programs). I’m trying to extend this to analyse queries made by one of these programs to the database, which uses the Hibernate ORM.
I’m looking at the Hibernate Interceptor and that seems quite interesting. How could I integrate the Interceptor into my program? I’m not sure how I can use it to connect with the other programs to listen for calls. Or would the Listener be a better choice?
Thanks, Harry
To Integrate Hibernate interceptor in your program, you have to follow these steps:
Create a class which extends hibernate’s EmptyInterceptor.
Implement the methods which are relevant to your requirement.
Set it to the Configuration, as
Configuration cfg = new Configuration();
cfg.setInterceptor(new YourInterceptor());