I'm looking into using Hibernate for a database project. We intend to have multiple clients on multiple systems making updates to the database, and we also want a task to be started on a particular system whenever a particular table is updated.
I've looked through Hibernate documentation and it looks like an Interceptor might solve our problem, but it says an Interceptor is started when the session updates the database. Does that mean it will only intercept updates by that particular process? I need a way to be informed of any update.
If an interceptor can't be triggered by a general update, is there something else that will work?
The Interceptor can tell you when an property on a persistent object is changed within the context of a particular Session or SessionFactory. So you could monitor all the data manipulation in one application's SessionFactory. Indeed, if you bound the SessionFactory to JNDI, you could monitor what is happening for every application that gets its SessionFatory from there.
What you can't do is know when another unrelated application updates a database table. The only thing that can tell you that is the database itself, there is no other application or API that can do it. And the only thing that a database is likely to give you to monitor data manipulation is a trigger. Communicating from a database trigger to all listening applications is going to be very awkward.
Some databases allow triggers to make calls to the OS of the host system (such as SQL Server). You could use this sort of machanism to call you process. Other databases such as Oracle support Java, so you could write your process in java and run it in the database. [ October 03, 2006: Message edited by: Paul Sturrock ]