tags:

views:

160

answers:

2

I want to tell hibernate to give me a callback notification when a new row is inserted into my database (this row is inserted by another system/application.)

Im using mysql cluster and replicates the databases within the cluster. As soon as some of the databases is changed the other systems must be informed about this change.

Is Hibernate supporting this kind of functionality? I assume I must have some kind of trigger or procedure on the database layer.

+4  A: 

You can register interceptors to monitor operations done by your application. But not other modifications AFAIK. The only solution I can think of is some kind of polling your database. Unless your DB has some way of notifying you about changes. But it must be your database not Hibernate.

Tadeusz Kopec
IIRC mysql supports trigger like "on insert do this". I think I must have something like this on the database.
Schildmeijer
A: 

As noted by tkopec, unless you have a way to have the database notify you (usually through some sort of network protocol) you would need to check the rows of the table in question at regular intervals. I do know that there are some modules available to do this for different databases, but I am not sure I can come up with a particular use case for it.

aperkins
thanks. if the database is updated from another source and your "main" application must be notified about this change. (im using mysql cluster to avoid the need of an external protocol for these synch issues)
Schildmeijer
Without knowing more about your specific application, I feel that I cannot add any more useful information. I know that in my (somewhat limited) experience, I have not found a need to do this. However, if that is the case, I wish you luck :)
aperkins