Just needs to be sure about this one (have told my coworker something else,
i think :)

The cached entities will still have correct == semantics, right ?

so, ...

s1 = sf.openSession();
p1 = s.load(Person.class, 42); // p is loaded from db and a copy of it is
put in the global cache
p2  = (Person)s.find("from p in Person where p.id =
42).list().iterator().next();
assertEquals(p,p1); // equals MUST hold
assertSame(p,p1); // but how about this one ? is p==p1 ? (which I would
expect :)
s.flush();
s.close();

s2 = sf.openSession();
p3 = s.load(Person.class, 42); // p is copied from cache
p4  = (Person)s.find("from p in Person where p.id =
42).list().iterator().next();
assertSame(p3,p4);
assertSame(p1,p3); // this one fails because of the copy-from-cache
semantics, right ? (which is ok)
s.flush();
s.close();

/max

----- Original Message -----
From: "Gavin King" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 18, 2003 4:30 AM
Subject: Re: [Hibernate] jcs cache


>
> The cache is not used for *queries*. It is used for calls to load()
> and for resolving associations.
>
> Also note that the cache does not store actual Vertex instances; it
> stores a *copy* of the state of the vertex. So an instance retrieved
> from the cache will always be a different instance from the one that
> went in there. This is essential to how Hibernate's multi-version-
> concurrency caching mechanism works. (Hibernate NEVER causes threads
> to block!)
>
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by: Thawte.com - A 128-bit supercerts will
> allow you to extend the highest allowed 128 bit encryption to all your
> clients even if they use browsers that are limited to 40 bit encryption.
> Get a guide here:http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0030en
> _______________________________________________
> hibernate-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
>



-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com - A 128-bit supercerts will
allow you to extend the highest allowed 128 bit encryption to all your 
clients even if they use browsers that are limited to 40 bit encryption. 
Get a guide here:http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0030en
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to