views:

343

answers:

1

Is there a solution available to subscribe for domain object changes for Hibernate or any other mainstream O/R mapping framework? For example if I have a table in a database called "Apple" I'd like to be able to say "notify me when any Apple object changed" or "notify me when field "colour" of any Apple object changed". Of course I'd expect not just "something changed" notification but rather a list of id's of changed objects or a list of changed objects. Would be nice such solution to be scalable.

to summarize requirements:

  1. All changes to a DB will go through an ORM
  2. It should be a complete solution where it's possible to place a subscription using an expression like "subscribe for Question q where q.title like '%hibernate%'" where "Question" is an entity (Java object mapped to a table in a database) I'm interested in updates for. No need to be a string query but there should be a generic way to place a request.
+3  A: 

Will all the changes that generate these notifications go through the ORM, or is it possible that data might be changed via JDBC or another application accessing the same database?

If all changes go through the ORM and you are using Hibernate, then you could use Hibernate's interceptors and events.

On the other hand, if all the changes to the data don't go through the ORM and the code that processes the notifications is fairly simple, database triggers might be a better bet.

Don
Hi Don. While Hibernate Interceptors and events can help me to implement my own solution, I'm looking for something complete and ready to use. pls see updated question. thanks.
Vladimir