IDEMPIERE-4307 Quick Entry always retrieve all fields from db (#83)

add cache for MField
This commit is contained in:
hengsin 2020-05-29 19:38:15 +08:00 committed by GitHub
parent e9e7486473
commit baac93f9e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 3 deletions

View File

@ -19,6 +19,8 @@ package org.compiere.model;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
import org.compiere.util.CCache;
/** /**
* Field Model * Field Model
@ -32,7 +34,30 @@ public class MField extends X_AD_Field
/** /**
* *
*/ */
private static final long serialVersionUID = 7124162742037904113L; private static final long serialVersionUID = 7243492167390659946L;
/** Cache */
private static CCache<Integer,MField> s_cache = new CCache<Integer,MField>(Table_Name, 20);
/**
*
* @param ctx
* @param AD_Field_ID
* @return MField
*/
public static MField get(Properties ctx, int AD_Field_ID)
{
Integer key = Integer.valueOf(AD_Field_ID);
MField retValue = s_cache.get (key);
if (retValue != null && retValue.getCtx() == ctx) {
return retValue;
}
retValue = new MField (ctx, AD_Field_ID, null);
if (retValue.get_ID () == AD_Field_ID) {
s_cache.put (key, retValue);
}
return retValue;
}
/** /**
* Standard Constructor * Standard Constructor

View File

@ -212,7 +212,7 @@ public class WQuickEntry extends Window implements EventListener<Event>, ValueCh
if (!gridtab.isLoadComplete()) if (!gridtab.isLoadComplete())
gridwindow.initTab(i); gridwindow.initTab(i);
for (GridField gridfield : gridtab.getFields()) { for (GridField gridfield : gridtab.getFields()) {
MField field = new MField(Env.getCtx(), gridfield.getAD_Field_ID(), null); MField field = MField.get(Env.getCtx(), gridfield.getAD_Field_ID());
if (field.isQuickEntry()) { if (field.isQuickEntry()) {
if (! isValidQuickEntryType(field.getAD_Reference_ID())) if (! isValidQuickEntryType(field.getAD_Reference_ID()))
continue; continue;