users@glassfish.java.net

RE: identityMapAccessor.invalidateAll() does not work :/

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Fri, 9 Nov 2007 08:22:45 -0500

Hello,
  You are calling invalidate on the incorrect session object. The Active Session backs the persistence context and is not where the TopLink shared cache resides. The shared cache resides within the ServerSession. Change your code to the following:

private IdentityMapAccessor getIdentityMapAccessor() {
    oracle.toplink.essentials.ejb.cmp3.EntityManager toplinkEm =
            (oracle.toplink.essentials.ejb.cmp3.EntityManager) em.getDelegate();
    return toplinkEm.getServerSession().getIdentityMapAccessor();
}

-----Original Message-----
From: Witold Szczerba [mailto:pljosh.mail_at_gmail.com]
Sent: Friday, November 09, 2007 7:32 AM
To: users_at_glassfish
Subject: identityMapAccessor.invalidateAll() does not work :/


Hi there,
I have problem. In my application, sometimes I have to modify
something in database from without my application (using independent
db connection like the one from [Runtime->Databases] in NetBeans).

When I do this, TopLink Essentials still does see old values because
of its cache.
The cure for that was supposed to be a special method of invalidating
TopLink cache, here is how I do it:

public void invalidateCache() {
    IdentityMapAccessor identityMapAccessor = getIdentityMapAccessor();
    identityMapAccessor.invalidateAll();
}
private IdentityMapAccessor getIdentityMapAccessor() {
    oracle.toplink.essentials.ejb.cmp3.EntityManager toplinkEm =
            (oracle.toplink.essentials.ejb.cmp3.EntityManager) em.getDelegate();
    return toplinkEm.getActiveSession().getIdentityMapAccessor();
}

I have invalidateCache method in my UtilityServiceBean, and whan I
change something in database I call it - but it does not work. After
calling invalidateCache, TopLink still return data from cache, not
from application. The only thing that works is to restart Glassfish :/

What is wrong?

Regards,
Witold Szczerba

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net