aspose file tools*
The moose likes Object Relational Mapping and the fly likes Can I be informed of a database update? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Can I be informed of a database update?" Watch "Can I be informed of a database update?" New topic
Author

Can I be informed of a database update?

Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
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?

Thanks,
Robert
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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 ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can I be informed of a database update?