Ok for everyone having the same problem. Here is what I have done. I don't like it so much, because the program has to refresh every object to look for changes, but if there aren't too much object to be monitored it should work.
Refresher
I have made a singelton (A Class with only one instance), which refreshes every given object with:
Code:
// Get the current session for refreshing
Session session = getCurrentSession();
session.beginTransaction();
// For every object to refresh
session.refresh(object);
session.getTransaction().commit();
the program has to give all object, to monitor to this class.
Object to refreshThe object, which should be refreshed need to have a setter methode in which the code is, what should happen if some data changed. In Example this could be to write it to the console:
Code:
public void setTitle(String title) {
if (this.title != null)
if (!this.title.equals(title))
System.out.println("Event\t\tTitle changed");
this.title = title;
}
It look whether the title changed and only write it then.
Issues
One issue I see is that the program has to refresh every object to look for changes. If the program isn't time critical it should no problem because it could be donne every second or even in a less frequency.
The other problem I see is, that the objects themselfs has to organise the callback. This should be done by the refresher or the monitoring objects.
I hope it works for every having the same problem. If there are some ideas to code this I would be happy to read them here.[/b]