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
|
* Get MColumn from Cache
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param AD_Column_ID id
|
* @param AD_Column_ID id
|
||||||
|
* @param trxName trx
|
||||||
* @return MColumn
|
* @return MColumn
|
||||||
*/
|
*/
|
||||||
public static MColumn get(Properties ctx, int AD_Column_ID, String trxName)
|
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)) {
|
if (DisplayType.TableDir == refid || (DisplayType.Search == refid && getAD_Reference_Value_ID() == 0)) {
|
||||||
foreignTable = getColumnName().substring(0, getColumnName().length()-3);
|
foreignTable = getColumnName().substring(0, getColumnName().length()-3);
|
||||||
} else if (DisplayType.Table == refid || DisplayType.Search == refid) {
|
} 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())) {
|
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());
|
int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM AD_Ref_Table WHERE AD_Reference_ID=?", getAD_Reference_Value_ID());
|
||||||
if (cnt == 1) {
|
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)
|
if (rt != null)
|
||||||
foreignTable = rt.getAD_Table().getTableName();
|
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)) {
|
|| (DisplayType.Search == getAD_Reference_ID() && getAD_Reference_Value_ID() == 0)) {
|
||||||
foreignTable = getColumnName().substring(0, getColumnName().length()-3);
|
foreignTable = getColumnName().substring(0, getColumnName().length()-3);
|
||||||
} else if (DisplayType.Table == getAD_Reference_ID() || DisplayType.Search == getAD_Reference_ID()) {
|
} 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())) {
|
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)
|
if (rt != null)
|
||||||
foreignTable = rt.getAD_Table().getTableName();
|
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
|
* Standard Constructor
|
||||||
|
@ -68,19 +68,27 @@ public class MRefTable extends X_AD_Ref_Table
|
||||||
/** Ref Table Cache */
|
/** Ref Table Cache */
|
||||||
private static CCache<Integer,MRefTable> s_cache = new CCache<Integer,MRefTable>(Table_Name, 20);
|
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
|
* Get from Cache
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param AD_Reference_ID id
|
* @param AD_Reference_ID id
|
||||||
|
* @param trxName trx
|
||||||
* @return category
|
* @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);
|
Integer ii = Integer.valueOf(AD_Reference_ID);
|
||||||
MRefTable retValue = (MRefTable)s_cache.get(ii);
|
MRefTable retValue = (MRefTable)s_cache.get(ii);
|
||||||
if (retValue != null)
|
if (retValue != null) {
|
||||||
|
retValue.set_TrxName(trxName);
|
||||||
return retValue;
|
return retValue;
|
||||||
retValue = new MRefTable (ctx, AD_Reference_ID, null);
|
}
|
||||||
|
retValue = new MRefTable (ctx, AD_Reference_ID, trxName);
|
||||||
if (retValue.get_ID () != 0)
|
if (retValue.get_ID () != 0)
|
||||||
s_cache.put (AD_Reference_ID, retValue);
|
s_cache.put (AD_Reference_ID, retValue);
|
||||||
return 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
|
* Standard Constructor
|
||||||
|
@ -61,19 +61,27 @@ public class MReference extends X_AD_Reference {
|
||||||
/** Reference Cache */
|
/** Reference Cache */
|
||||||
private static CCache<Integer,MReference> s_cache = new CCache<Integer,MReference>(Table_Name, 20);
|
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
|
* Get from Cache
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param AD_Reference_ID id
|
* @param AD_Reference_ID id
|
||||||
|
* @param trxName trx
|
||||||
* @return category
|
* @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);
|
Integer ii = Integer.valueOf(AD_Reference_ID);
|
||||||
MReference retValue = (MReference)s_cache.get(ii);
|
MReference retValue = (MReference)s_cache.get(ii);
|
||||||
if (retValue != null)
|
if (retValue != null) {
|
||||||
|
retValue.set_TrxName(trxName);
|
||||||
return retValue;
|
return retValue;
|
||||||
retValue = new MReference (ctx, AD_Reference_ID, null);
|
}
|
||||||
|
retValue = new MReference (ctx, AD_Reference_ID, trxName);
|
||||||
if (retValue.get_ID () != 0)
|
if (retValue.get_ID () != 0)
|
||||||
s_cache.put (AD_Reference_ID, retValue);
|
s_cache.put (AD_Reference_ID, retValue);
|
||||||
return retValue;
|
return retValue;
|
||||||
|
|
Loading…
Reference in New Issue