0

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?

  • 1
    I 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: http://stackoverflow.com/questions/11127943/connect-to-web-service-api-in-mysql – David Fleeman Jan 07 '14 at 21:09

1 Answers1

0

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

polypiel
  • 2,321
  • 1
  • 19
  • 27