public void test() { int size = getCacheIdentityMap().getMaxSize() * factor; for (int i = 0; i < size; i++) { BigDecimal id = new java.math.BigDecimal(i); Employee employee = new Employee(); Vector pk = new Vector(1); employee.setId(id); employee.setFirstName("Joe"); employee.setLastName("Blow"); pk.add(id); getPrimaryKeys().add(pk); getCacheIdentityMap().put(primaryKeys, employee, null, 0); } }
public void test() { Vector primaryKeys = new Vector(); primaryKeys.add(new java.math.BigDecimal(4)); CacheKey cacheKey = getAbstractSession() .getIdentityMapAccessorInstance() .acquireDeferredLock( primaryKeys, Employee.class, getSession().getDescriptor(Employee.class), false); CacheKey cacheKey2 = getAbstractSession() .getIdentityMapAccessorInstance() .acquireDeferredLock( primaryKeys, Employee.class, getSession().getDescriptor(Employee.class), false); if (cacheKey != cacheKey2) { throw new TestErrorException( "WeakIdentityMap failed to return same cachkey for successive calls for same primary key and class"); } // must release because the deferred lock is not removed on an initialize identity map cacheKey.releaseDeferredLock(); cacheKey2.releaseDeferredLock(); }