ahh...

You're absolutely right.  I just changed and tested with:
       // Check if findByPrimaryKey
       // If so we check if the entity is in cache first
       if (finderMethod.getName().equals("findByPrimaryKey"))
       {
          Object key = ctx.getCacheKey();
          if (key == null)
          {
             key =
((EntityCache)con.getInstanceCache()).createCacheKey(args[0]);
          }          if (con.getInstanceCache().isActive(key))
             return key; // Object is active -> it exists 

thanks
The code actually works the other way, because in the constructor for
org/jboss/ejb/plugins/jrmp/interfaces/EntityProxy.java (line 80) we have:

      if (id instanceof CacheKey) {
         this.cacheKey = (CacheKey) id;
      }
      else
      {
         // In case we pass the Object or anything else we encapsulate
         cacheKey = new CacheKey(id);
      }
So it was just Marshalling a new CacheKey for me.  (which Im sure is
inefficient).

Incidentally, in the BMP code we are also getting a new cache key created
every time, because callFinderMethod() returns the id and then in findEntity
we create a new cache key for it.  Im sure that the marshalling involved is
not free, and in any case it doesnt make sense to put the code to handle
findByPrimaryKey in a method (callFinderMethod) that is meant to handle
multi-finders.  I think we should move the above code from
BMPPersistenceManager.callFinderMethod (line 433) to
BMPPersistenceManager.findEntity (line 210) and return the key instead of
re-creating it.

-----Original Message-----
From: Bordet, Simone [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 15, 2001 4:53 AM
To: 'JBoss-User'
Subject: RE: [jBoss-User] RE: Why doesn't CMP findByPrimaryKey lookup on
c ache?


Hey David,

see below.

>       // Check if findByPrimaryKey
>       // If so we check if the entity is in cache first
>       if (finderMethod.getName().equals("findByPrimaryKey"))
>       {
>          Object key = ctx.getCacheKey();
>          if (key == null)
>          {
>             key =
> ((EntityCache)con.getInstanceCache()).createCacheKey(args[0]);
>          }
>          if (con.getInstanceCache().isActive(key))
>             return args[0]; // Object is active -> it exists 

Here you'd better return key (not args[0]).

Simon


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to