-->
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: Inter-session caching question
PostPosted: Sat Nov 15, 2003 2:33 pm 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Hi,

I have a set of persistent objects, TaskPriority, which I preload when the server starts (in a HashMap)

Each call from the client implies a new session, while the caching was done in another session. Is that dangerous?

Now I get:

java.lang.NullPointerException: not-null property references a null or transient value: Task.priority

...when I save() on an object referrering to the previously cached priority object, despite the fact that the priority object has a valid ID.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 15, 2003 3:13 pm 
Senior
Senior

Joined: Tue Oct 21, 2003 8:15 am
Posts: 186
Uhm... yes, caching the stuff in the same session solved the problem, but that defeats the purpose of the caching...

How can I cache in one session and add cached objects in another? Cached objects never change.

Thought saveOrUpdate would help, but it didn't

Ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 15, 2003 9:19 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 7:53 pm
Posts: 66
Location: Lakeland, Florida USA
Look into the new, lightweight HashtableCacheProvider and query caching functionality, using Query.setCacheable(true).

Jeff


Top
 Profile  
 
 Post subject: Re: Inter-session caching question
PostPosted: Mon Nov 17, 2003 4:19 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
nickvajberg wrote:
...when I save() on an object referrering to the previously cached priority object, despite the fact that the priority object has a valid ID.
...
Thought saveOrUpdate would help, but it didn't

Since the object has been saved previously, then you must update it instead of saving it. So saveOrUpdate would help if unsaved-value is set properly and the id is not assigned.

However, the first session must be flushed before the second one access to it. Otherwise, the second session will query a non updated DB

_________________
Emmanuel


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.