diff --git a/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java b/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java index bfc20cb5bb..65d041dd29 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java @@ -31,6 +31,7 @@ import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.KeyNamePair; import org.compiere.util.NamePair; +import org.compiere.util.Util; /** * Warehouse Locator Lookup Model. @@ -255,7 +256,7 @@ public final class MLocatorLookup extends Lookup implements Serializable return null; } // - return new MLocator (m_ctx, M_Locator_ID, trxName); + return Util.isEmpty(trxName) ? MLocator.get(m_ctx, M_Locator_ID) : new MLocator (m_ctx, M_Locator_ID, trxName); } // getMLocator /** @@ -328,7 +329,7 @@ public final class MLocatorLookup extends Lookup implements Serializable int local_only_warehouse_id = getOnly_Warehouse_ID(); // [ 1674891 ] MLocatorLookup - weird error int local_only_product_id = getOnly_Product_ID(); - StringBuilder sql = new StringBuilder("SELECT M_Locator.* FROM M_Locator ") + StringBuilder sql = new StringBuilder("SELECT M_Locator.M_Locator_ID FROM M_Locator ") .append(" INNER JOIN M_Warehouse wh ON (wh.M_Warehouse_ID=M_Locator.M_Warehouse_ID) ") .append(" WHERE M_Locator.IsActive='Y' ") .append(" AND wh.IsActive='Y'"); @@ -372,8 +373,8 @@ public final class MLocatorLookup extends Lookup implements Serializable // while (rs.next()) { - MLocator loc = new MLocator(m_ctx, rs, null); - int M_Locator_ID = loc.getM_Locator_ID(); + int M_Locator_ID = rs.getInt(1); + MLocator loc = MLocator.get(m_ctx, M_Locator_ID); m_lookup.put(new Integer(M_Locator_ID), loc); } } diff --git a/org.adempiere.base/src/org/compiere/util/CacheMgt.java b/org.adempiere.base/src/org/compiere/util/CacheMgt.java index b8c6e53f40..bd7895716e 100644 --- a/org.adempiere.base/src/org/compiere/util/CacheMgt.java +++ b/org.adempiere.base/src/org/compiere/util/CacheMgt.java @@ -18,8 +18,10 @@ package org.compiere.util; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import java.util.Map.Entry; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.logging.Level; @@ -66,6 +68,7 @@ public class CacheMgt /** Logger */ private static CLogger log = CLogger.getCLogger(CacheMgt.class); + private final static int MAX_SIZE = 2000; /************************************************************************** * Create Cache Instance @@ -94,7 +97,18 @@ public class CacheMgt if (map == null) { - map = new ConcurrentHashMap(); + map = Collections.synchronizedMap(new LinkedHashMap() { + /** + * generated serial id + */ + private static final long serialVersionUID = -9111152673370957054L; + + @Override + protected boolean removeEldestEntry(Entry eldest) { + return size() > MAX_SIZE; + } + + }); } return map; } // register