2

I'm writing a server side application that will monitor changes to a database, I plan to do this with Hibernate. I'd like to set up a listener so that if any changes are made to the data any registered observers can be told there is an update and send a separate request to pull it.

I've read about Hibernate envers as well as the AuditEventListener. My question is though seeing as my application will only get data and not set it, can the Envers listeners listen to changes in tables that are NOT made by my application?

4

1 回答 1

1

更新:

不,监听器只是 NH​​ibernate 中的钩子,它只监听设置了 Enverslisteners 的 Hibernate 会话所做的更改。

您正在寻找的是触发器或数据库事件。我使用触发器对 Postgresql 进行了概念验证,listennotify似乎在某些条件下工作。尽管它对于 Postgresql 使用的体系结构对于每个支持某种通知系统的 SQL 数据库都是相同的。

对于甲骨文:

  • 为更改创建回调,请参见此处
  • 在某个表中写入更改信息
  • 在您的应用程序中轮询更改信息表以查看是否有更改并处理它们
于 2012-01-11T13:06:47.657 回答