-->
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: find and refresh cache
PostPosted: Wed Sep 03, 2003 5:14 am 
Newbie

Joined: Wed Sep 03, 2003 4:59 am
Posts: 12
Hy,

When we use find(), does it overide the cache ?

If I do
session.find("From foo");
Am I sure that every objects are in the cache with a lifeTime = 0 ?

Thanks
joe[/quote]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 03, 2003 5:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ahh this is slightly subtle.


For any Foos which are NOT already cached by the session, yes, we bypass the cache. But we do NOT bypass the cache when subsequently resolving associations.


Top
 Profile  
 
 Post subject: precisions
PostPosted: Wed Sep 03, 2003 6:19 am 
Newbie

Joined: Wed Sep 03, 2003 4:59 am
Posts: 12
Thanks for response,

So, if I have a class

public class foo{
String id;
String state;
Bar myBar; // many-to-one
... getters and setters...
}


If my instance in the cache have :
id = "THISONE"
state = "unmodified"
myBar = "someBarWithIdEquals1"

and in the database there is an update of the foo :
id = "THISONE"
state = "justModified"
myBar = "anotherBarWithIdEquals2"

Now, I call session.find("From Foo");

and then if I call session.load(Foo.class, "THISONE");
do I get this :
id = "THISONE"
state = "justModified"
myBar = "null" (that will be fill with "anotherBarWithIdEquals2" when I call the getter)

?

Joe


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 03, 2003 6:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
load() will, of course, return the same instance that was returned by find()


it is fundamental property of Hibernate that there is maximum one-instance-per row in a particular session


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 03, 2003 6:26 am 
Newbie

Joined: Wed Sep 03, 2003 4:59 am
Posts: 12
Thanks for Reply.

It is a GREAT stuff that you realised here.

Thanks again
joe


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.