IDEMPIERE-4097 AD_Reference Caching validation / fix warning in 2Pack about Reference not found
This commit is contained in:
parent
e735c686ca
commit
8405e2a494
|
@ -63,6 +63,7 @@ public class MColumn extends X_AD_Column
|
|||
* Get MColumn from Cache
|
||||
* @param ctx context
|
||||
* @param AD_Column_ID id
|
||||
* @param trxName trx
|
||||
* @return MColumn
|
||||
*/
|
||||
public static MColumn get(Properties ctx, int AD_Column_ID, String trxName)
|
||||
|
@ -807,11 +808,11 @@ public class MColumn extends X_AD_Column
|
|||
if (DisplayType.TableDir == refid || (DisplayType.Search == refid && getAD_Reference_Value_ID() == 0)) {
|
||||
foreignTable = getColumnName().substring(0, getColumnName().length()-3);
|
||||
} else if (DisplayType.Table == refid || DisplayType.Search == refid) {
|
||||
MReference ref = MReference.get(getCtx(), getAD_Reference_Value_ID());
|
||||
MReference ref = MReference.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
|
||||
if (MReference.VALIDATIONTYPE_TableValidation.equals(ref.getValidationType())) {
|
||||
int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM AD_Ref_Table WHERE AD_Reference_ID=?", getAD_Reference_Value_ID());
|
||||
if (cnt == 1) {
|
||||
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID());
|
||||
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
|
||||
if (rt != null)
|
||||
foreignTable = rt.getAD_Table().getTableName();
|
||||
}
|
||||
|
|
|
@ -297,9 +297,9 @@ public class MProcessPara extends X_AD_Process_Para
|
|||
|| (DisplayType.Search == getAD_Reference_ID() && getAD_Reference_Value_ID() == 0)) {
|
||||
foreignTable = getColumnName().substring(0, getColumnName().length()-3);
|
||||
} else if (DisplayType.Table == getAD_Reference_ID() || DisplayType.Search == getAD_Reference_ID()) {
|
||||
MReference ref = MReference.get(getCtx(), getAD_Reference_Value_ID());
|
||||
MReference ref = MReference.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
|
||||
if (MReference.VALIDATIONTYPE_TableValidation.equals(ref.getValidationType())) {
|
||||
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID());
|
||||
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
|
||||
if (rt != null)
|
||||
foreignTable = rt.getAD_Table().getTableName();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class MRefTable extends X_AD_Ref_Table
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -699466856436251075L;
|
||||
private static final long serialVersionUID = -3595900192339578282L;
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
|
@ -68,19 +68,27 @@ public class MRefTable extends X_AD_Ref_Table
|
|||
/** Ref Table Cache */
|
||||
private static CCache<Integer,MRefTable> s_cache = new CCache<Integer,MRefTable>(Table_Name, 20);
|
||||
|
||||
public static MRefTable get (Properties ctx, int AD_Reference_ID)
|
||||
{
|
||||
return get (ctx, AD_Reference_ID, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get from Cache
|
||||
* @param ctx context
|
||||
* @param AD_Reference_ID id
|
||||
* @param trxName trx
|
||||
* @return category
|
||||
*/
|
||||
public static MRefTable get (Properties ctx, int AD_Reference_ID)
|
||||
public static MRefTable get (Properties ctx, int AD_Reference_ID, String trxName)
|
||||
{
|
||||
Integer ii = Integer.valueOf(AD_Reference_ID);
|
||||
MRefTable retValue = (MRefTable)s_cache.get(ii);
|
||||
if (retValue != null)
|
||||
if (retValue != null) {
|
||||
retValue.set_TrxName(trxName);
|
||||
return retValue;
|
||||
retValue = new MRefTable (ctx, AD_Reference_ID, null);
|
||||
}
|
||||
retValue = new MRefTable (ctx, AD_Reference_ID, trxName);
|
||||
if (retValue.get_ID () != 0)
|
||||
s_cache.put (AD_Reference_ID, retValue);
|
||||
return retValue;
|
||||
|
|
|
@ -33,7 +33,7 @@ public class MReference extends X_AD_Reference {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 119105464164520763L;
|
||||
private static final long serialVersionUID = 343092563490562893L;
|
||||
|
||||
/**
|
||||
* Standard Constructor
|
||||
|
@ -61,19 +61,27 @@ public class MReference extends X_AD_Reference {
|
|||
/** Reference Cache */
|
||||
private static CCache<Integer,MReference> s_cache = new CCache<Integer,MReference>(Table_Name, 20);
|
||||
|
||||
public static MReference get (Properties ctx, int AD_Reference_ID)
|
||||
{
|
||||
return get(ctx, AD_Reference_ID, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get from Cache
|
||||
* @param ctx context
|
||||
* @param AD_Reference_ID id
|
||||
* @param trxName trx
|
||||
* @return category
|
||||
*/
|
||||
public static MReference get (Properties ctx, int AD_Reference_ID)
|
||||
public static MReference get (Properties ctx, int AD_Reference_ID, String trxName)
|
||||
{
|
||||
Integer ii = Integer.valueOf(AD_Reference_ID);
|
||||
MReference retValue = (MReference)s_cache.get(ii);
|
||||
if (retValue != null)
|
||||
if (retValue != null) {
|
||||
retValue.set_TrxName(trxName);
|
||||
return retValue;
|
||||
retValue = new MReference (ctx, AD_Reference_ID, null);
|
||||
}
|
||||
retValue = new MReference (ctx, AD_Reference_ID, trxName);
|
||||
if (retValue.get_ID () != 0)
|
||||
s_cache.put (AD_Reference_ID, retValue);
|
||||
return retValue;
|
||||
|
|
Loading…
Reference in New Issue