• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How might an application listen for changes in database?

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if this is the right forum, but I had the following question.

I want to build an application that dynamically updates its GUIs (Google Web Toolkit) whenever the underlying relational database is changed. In this application database updates might be done about every 20 seconds.

How might a Java application listen for changes in a database?

I presume that a persistence layer would have to do the listening? Can, for example, a JPA EntityManager listen for changes?

There would not be any way do notify from the database itself, would there be? (Triggers remain solely in SQL, I think). I would not think so.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using hibernate you can use a session interceptor.
You can find more details here: http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/events.html
 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Bogdan. I will have a look at that link.

I wonder if JPA offers similar classes. This hint that
in Hibernate it is an interceptor is useful.
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic