User: simone
Date: 01/02/27 16:03:51
Modified: src/main/org/jboss/ejb/plugins CMPPersistenceManager.java
Log:
Optimized findByPrimaryKey calls: if the bean is already in the cache we return it
immediately without calling the finder.
Revision Changes Path
1.17 +15 -2 jboss/src/main/org/jboss/ejb/plugins/CMPPersistenceManager.java
Index: CMPPersistenceManager.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/CMPPersistenceManager.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- CMPPersistenceManager.java 2001/01/26 20:31:24 1.16
+++ CMPPersistenceManager.java 2001/02/28 00:03:51 1.17
@@ -42,7 +42,7 @@
*
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.16 $
+* @version $Revision: 1.17 $
*/
public class CMPPersistenceManager
implements EntityPersistenceManager {
@@ -252,12 +252,25 @@
public Object findEntity(Method finderMethod, Object[] args,
EntityEnterpriseContext ctx)
throws Exception {
+ // For now only optimize fBPK
+ 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 -> no need to call finder
+ }
+ }
// The store will find the entity and return the primaryKey
Object id = store.findEntity(finderMethod, args, ctx);
// We return the cache key
- return ((EntityCache) con.getInstanceCache()).createCacheKey(id);
+ return ((EntityCache) con.getInstanceCache()).createCacheKey(id);
}
public Collection findEntities(Method finderMethod, Object[] args,
EntityEnterpriseContext ctx)