-->
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.  [ 5 posts ] 
Author Message
 Post subject: Refresh after update
PostPosted: Tue Apr 29, 2008 1:39 pm 
Beginner
Beginner

Joined: Wed Mar 05, 2008 10:32 am
Posts: 48
I'm seeing an issue with cacheing. I'm not sure if this is a setting to be altered using hibernate or something else.

So on a login screen i have some stats i'm showing to the user, one being their favorite venues.

Code:
   @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, fetch=FetchType.EAGER)
   @org.hibernate.annotations.Cascade(value = {org.hibernate.annotations.CascadeType.SAVE_UPDATE})
   public Set<VenueEnt> getFavoriteVenues() {
      return favoriteVenues;
   }


after i navigate to a new page and add a new venue to my favorites (using DWR ajax), i can see the new values being added to the DB.
When i return to the login page, i dont see the updated list. I thought that those cascade settings would force hibernate to requery the list.

Here is the code on the page.
Code:
         <%    Set<VenueEnt> favs = user.getFavoriteVenues();
            for (VenueEnt v : favs){
               out.println("<li><a href='Venue?venueId=" + v.getId() + "'>" + v.getName() + "</a></li>");
            }
         %>


I should also mention that after a forced refresh (F5 or CTRL R) the results stay the same :(

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 29, 2008 8:37 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
How are you adding the new items to the collection? If you're using merge(), don't forget that the return value of merge() is the merged copy. If you're storing the User around somewhere it is now going to be stale...

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 30, 2008 4:07 am 
Regular
Regular

Joined: Mon Aug 06, 2007 10:49 am
Posts: 67
Location: Banska Bystrica, Slovakia
did u perform refresh on main object?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 30, 2008 10:47 am 
Beginner
Beginner

Joined: Wed Mar 05, 2008 10:32 am
Posts: 48
CORRECT!
After commiting the transaction i never updated the User session object. That aught to do it.

Thanks!

Now i'm doing this update by calling a servlet using ajax, is there a way to know when the servlet has completed? The idea is that onclick, run servlet, on complete, if status of servlet (using a session var) is good, then change area on page using ajax.

I'm thinking of using a js delay to check the session var after click (that could potentially not exist) and do the rest, but i fear that the delay is not a safe method of doing this.

Any tips?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 30, 2008 11:30 am 
Newbie

Joined: Wed Apr 30, 2008 11:26 am
Posts: 1
in the place where u saves after commit:

EntityManagerHelper.getEntityManager().refresh(<user entity>);

_________________
Thank you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.