-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Refresh hibernate connection -- reload data from database
PostPosted: Fri Dec 09, 2005 11:05 am 
Newbie

Joined: Fri Nov 11, 2005 12:55 pm
Posts: 6
Hello all,

I have java GUI application which uses hibernate to load all data from database. Once the application is executed, it loads all required data from database to java application and diplays data on java GUI. But now if someone adds data directly in database through other third party application, the Java GUI application doesn't reflect those changes. To view the newly added data in database, we need to close Java GUI application and start it again. It would be good if there is any refresh command on the hibernate side which should re-load all data from database so we don't need to restart java GUI application.
Is there any refresh command on the hibernate side which would reload all data in Java application?

Thanks
Prashant


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 09, 2005 3:31 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
sounds like you have a design problem.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 09, 2005 5:16 pm 
Newbie

Joined: Mon Jul 18, 2005 10:15 am
Posts: 17
What caching mechanism are you using?
JB


Top
 Profile  
 
 Post subject: Re: Refresh hibernate connection -- reload data from databas
PostPosted: Sat Dec 10, 2005 3:24 pm 
Regular
Regular

Joined: Sun May 08, 2005 2:48 am
Posts: 118
Location: United Kingdom
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.