it's a(/my) bug in ObjectCacheDefaultImpl (rc5) causing this strange behaviour. I will check in a fixed version tomorrow.
More info see thread 'Usage WeakHashMap in AnonymousPersistentField Re: Cache and prefetched relationships'
regards, Armin
Jair da Silva Ferreira Júnior wrote:
Hi, I am using ojb1.0_rc5, ODMG api with OJB queries, mysql4 (innodb tables) in Linux Red Hat 7.3 (kernel 2.4.20-20.7). I moved from rc4 to rc5 recently and I noticed that sometimes when I run a query the resulting associated objects don't come from the cache. Please, take a look at the above code to better undestand what I am saying:
Transaction t=implementation.newTransaction();
t.begin();
Person p=new Person();
t.lock(p,t.WRITE);
p.setName("somebody");
Dog d=new Dog();
t.lock(d,t.WRITE);
d.setName("Spike");
p.setDog(d);
t.commit();
t=implementation.newTransaction();
t.begin();
Criteria crit=new Criteria();
crit.addEqualTo("_id",new Integer(p.getId()));
QueryByCriteria query=QueryFactory.newQuery(Person.class,crit);
PersistenceBroker broker=((HasBroker)t).getBroker();
broker.removeFromCache(p);
Person loaded=(Person)broker.getObjectByQuery(query);
boolean cacheOk=(loaded.getDog()==d); //here cacheOk==false sometimes
t.commit();
The atributes (proxy, refresh, auto-retrieve, auto-update and auto-delete) in the reference-descriptor for the association between Person and Dog have default values. This way, refresh="false".
This problem does not happen everytime. So, sometimes cacheOk==true.
I wasn't able to reproduce this problem in a test case, but it does happen sometimes.
I've used rc4 for a long time and I've never had this kind of problem.
Here's my cache configuration in OJB.properties:
ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl descriptorBasedCaches=false
Thanks, Jair Jr
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]