File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Spring DAO Session refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring DAO Session refresh " Watch "Spring DAO Session refresh " New topic
Author

Spring DAO Session refresh

Baskar Sikkayan
Greenhorn

Joined: Oct 06, 2011
Posts: 16
Hi,
I have a login page and once the user is logged in i will add the user object in the servlet session.
This user table has one to many relationships with many tables. One of the table is EmploymentDetails.
One user might have more than one entry in employment table.
When the user wants to see the employment details, he will be taken to the employment details page.
So in the controller, i will do the following before taking him to the jsp page.

Part of the code :

usersDAO.attachClean(user); // Here i am attaching the user to the hibernate session.

Set<EducationalDetails> educationDetailsSet = user.getEmploymentDetailses();

Once the user is taken to the jsp page,

if i refresh the page again, the query is not fired as the data is fetched from the Hibernate session.
But, some one else has modified the data in between directly in the table.
But these modified data are not reflected in the JSP page as it still fetch values from hibernate session.

How to prevent this?

If i need to add session.refresh(), Will it trigger the query every time when i refresh the page?
If it is so, how to improve the performance as it has to hit the DB every time?

Also, i have an add button in the screen. On clicking this user will be taken to a page wherein he can add the new employment details.
On submitting the page, the user will agin taken back to the Employment details page. But unable to see the newly added records.


Thanks,
Baskar.S


Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Are you saying there is some other program that changes the tables without using Hibernate?

If that is the case then yes you will have to refresh and it has to be a hit to DB since DB is refreshed.


===Vyas Sanzgiri===
My Blog
abani patra
Ranch Hand

Joined: Oct 11, 2011
Posts: 70
Hi,
Instead of storing the user in session better will if you use any security API like jsecurity, shiro etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spring DAO Session refresh