ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Meindert" <meind...@pastelebusiness.com>
Subject Cache object reference
Date Wed, 06 Jun 2007 09:26:00 GMT


This isn't so much a question more an issue I had using cache.

Is it by design that the object returned from the cache has the same object
reference as the on in the cache?


What I mean (and what I encountered) is this;

Object a = queryoutofcache;   //Cache miss a new object a is created

Object b = queryoutofcache;   //Cache hit object reference to b==object
reference to object a!


Thus changes I made on object a are also made on object b!  This had very
nasty effects!



A email is send by Bob to receiver Bob, but if I change the name of the
sender to Alice the name of the receiver also changes to Alice!

Person sender = (Person) queryoutofcache; //Cache miss sender is created

Person receiver = (Person) queryoutofcache; ;   //Cache hit, receiver is NOT
created, it is pointing to the sender object


Kind Regards





View raw message