Announcement Announcement Module
Collapse
No announcement yet.
Ability to capture table update events Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ability to capture table update events

    Hi -

    I have a spring managed application that partly uses Hibernate to persist data. Another part of this application uses direct SQL to insert/update/read/delete table records into the same database. Is there a way to configure Spring so that I could be informed of an update made to one of the non-Hibernate managed tables and process the data involved in that update?

    For example: There could be two tables called: BOOK and MEMBER. BOOK was created by SQL whereas MEMBER was created using Hibernate to indicate that a 'member' could borrow a 'book'. Hence an attempt to remove a 'book' should not be allowed if it is held by a 'member'.

    This could be done using a foreign key constraint but I am looking for a Spring approach. Perhaps if a record from table BOOK is deleted, Spring could signal an event with the 'book' ID so that the application server could prevent that from happenning?

    Thanks for any inputs.

  • #2
    It's best to add such constrains at the db level or, at most, at Hibernate level since it's a java representation of the database.
    If both the HB and SQL application are in java and inside the same JVM you can hook them up to use the same transaction manager and the same connection. This way you have a very safe and fast way that guarantees database integrity.
    If you are going to process the constrains at the application level you are going to just rewrite and reinvent the features that are already available inside your database.

    Comment


    • #3
      Thanks for your response.

      Comment

      Working...
      X