wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes How might an application listen for changes in database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How might an application listen for changes in database? " Watch "How might an application listen for changes in database? " New topic
Author

How might an application listen for changes in database?

Benjamin Weaver
Ranch Hand

Joined: Apr 08, 2003
Posts: 161
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.
Bogdan Baraila
Ranch Hand

Joined: May 23, 2011
Posts: 43
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

Joined: Apr 08, 2003
Posts: 161
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How might an application listen for changes in database?