开发者

change notification on domain objects (Hibernate/Java)

开发者 https://www.devze.com 2022-12-09 13:13 出处:网络
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

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 "Ques开发者_Python百科tion" 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消