-->
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: lists of objects (missing update)
PostPosted: Wed Dec 14, 2005 12:35 pm 
I am seeing something, that I am sure I just don't understand right.

I have an ACCOUNT which has a relationship of one to many ADDRESSES. All this runs in a WebService. I exposed two methods: GetAddresses and AddAddress. Both take an account ID. So I fetch the account and return the associated addresses. When I need to add an address I simply fetch an account, then create a new address. I don't update Account.Addresses, just save the object.

The problem is that I don't get the updated list back on the next query to GetAddresses (the new address is not there).

So what's the right way of doing this? Do I need to update the list all the time or set some parameters on the relationships?

Thx
dB.


Top
  
 
 Post subject:
PostPosted: Wed Dec 14, 2005 1:35 pm 
Newbie

Joined: Wed Dec 07, 2005 12:32 am
Posts: 11
Location: Chennai, India
Could you post the mapping file?
Also, can u post the part of the code that adds the address & saves the object?

That would help in analyzing...

_________________
Thanks & Regards,
~Venki


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 14, 2005 1:38 pm 
Regular
Regular

Joined: Fri Jun 11, 2004 6:27 am
Posts: 81
Location: Yaroslavl, Russia
If save of new address completes successfully (think you have already checked it in the database) then there could be two reasons:
1. Your account object along with associated collection of addresses is cached in the session cache.
2. Collection of addresses for your account is cached in the second-level cache.

In first case it should be enough to evict account after you add an address.

In second - you can evict addresses collection from second-level cache (using SessionFactory.EvictCollection method).

But it would be much simpler if you will just add address to the collection and save whole account object.

_________________
Best,
Andrew Mayorov // BYTE-force


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 14, 2005 3:41 pm 
Newbie

Joined: Wed Dec 14, 2005 3:29 pm
Posts: 16
xor wrote:
But it would be much simpler if you will just add address to the collection and save whole account object.


It doesn't seem to quite work. The problem is accross sessions. This is an ASP.NET application (and I am keeping the session within the HTTP context). A second session doesn't see the results until a few seconds - clear problem in caching.

Am I doing something wrong or is this by design? Should I be flushing the second level cache for all the sessions to be updated?


Top
 Profile  
 
 Post subject: duh
PostPosted: Wed Dec 14, 2005 5:26 pm 
Newbie

Joined: Wed Dec 14, 2005 3:29 pm
Posts: 16
I fount my problem. I was forgetting to close the hibernate session at the end of the request.

Thanks to all!


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.