prashantnita wrote:
Is there any refresh command on the hibernate side which would reload all data in Java application?
What sort of modifications are you talking about ? The Adding or new rows to the table or the modification of column values within existing rows ?
How are those modifications themselves made at the SQL server ? By JDBC, by Hibernate (using a different SessionFactory) or by Hibernate using the same SessionFactory or Session ?
I have some long running application code that picks up data using Hibernate but external modifications can be made to it by JDBC.
My application loads a working set of data, when periodically (or though a trigger) it can reload one (or all) the rows again.
Before I do the Hibernate.get() to reload I always call Session.clear() to flush out any cached copies to force an SQL SELECT through to the database.
The results are then compared and merged into the working set and modification events get fired off within my application (depending upon what was changed).
Part of the merging I implemented Comparable interface in my POJO class storing the data, its a pretty custom implementation but it does the trick to allow a simple obj.compareTo(otherObj) between working set and freshly loaded copy.
If you are using a Java GUI with SWT/JFace its probably possible to reload the data without disrupting the GUI that much. Otherwise you maybe better off having a Refresh button the user can press to start over.