• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring DAO Session refresh

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Instead of storing the user in session better will if you use any security API like jsecurity, shiro etc.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic