0

I'm recently working on a legacy system. Which don't have detailed design document well reserved.

Inside the system, there is a Object-Relationship Mapping library we made many years ago. And it has a subscribe-notify mechanism. Clients (from different process) can subscribe a table so that if there is any change, they will be notified. The system heavily rely on this.

Since nobody in the team can answer this, I want to ask the community, is that a common practice for ORM? What will be alternative means to response data changes?

Archer
  • 507
  • 1
  • 8
  • 21
  • I think this is a good feature because the processes intended to be notified of changes don't need to poll the database constantly. Some DBMS even have built-in support for this kind of things. –  Jul 29 '14 at 06:30

3 Answers3

0

Why wouldn't an ORM have a pub/sub system?

Maybe you want to clear your ORM cache when a table changes.

Maybe you want to clear a web server cache when a table changes.

Maybe you want to send a websocket message to a browser when a table changes.

Look at Stackoverflow. If someone edits a question while you're answering it, there's a notification.

Neil McGuigan
  • 46,580
  • 12
  • 123
  • 152
  • But Hibernate and Entity Framework don't have built-in for this, Right? Correct me if I am wrong. Those listed are good reasons to listen to table changes. But what I'm really wondering is, is it part of ORM, or there is better place in the system to do so. Thanks! – Archer Jul 29 '14 at 06:49
  • That's true, it doesn't. It'd be nice if it did. EclipseLink does, for Oracle at least. You don't need to do it in the ORM, you could do it in plain old JDBC too. – Neil McGuigan Jul 29 '14 at 06:50
0

Pub/sub system is good if you want to get notified to changes in database table.One other method to do this is to continuously poll the database for any changes.But I don't think it is a good practice as it will just keep resources busy unnecessarily.

Atul Sharma
  • 718
  • 4
  • 11
0

We can compare pub/sub ORM functionality to database triggers. In both cases we can listen for database DML events on tables with granularity down to a single column and then perform action per each event. There are a lot of opinionated texts on the web on how and why triggers can complicate everyone's life and I think those sentiments are well applicable to ORM pub/sub.

Here are some opinions on the problems with triggers I can totally relate to:

https://www.red-gate.com/simple-talk/sql/oracle/the-problem-with-triggers/

When are database triggers bad?

twinmind
  • 1,440
  • 13
  • 21