I'm trying to create a simple .java class that simply runs and listens/watches a bunch of tables in a MySQL schema for any CRUD changes. How could I go about doing this? Would Hibernate have something that I could use?
-
1I would use a trigger that calls out to a UDF to invoke a web service in your Java app. This essentially would act as MySQL publishing the event to Java so that you do not need to poll. The solution is a little more flushed out here: stackoverflow.com/questions/11127943/…David Fleeman– David Fleeman2014-01-07 21:09:44 +00:00Commented Jan 7, 2014 at 21:09
Add a comment
|
1 Answer
You can use a Hibernate Inceptor.
First implement the abstract class EmptyInterceptor. There are several methods to intercept, but for a CRUD I think you'll have to override onSave, onLoad and onDelete.
Then register your interceptor on Hibernate configuration, method Configuration.setInterceptior