From 57c8b13b98c833f81af401b3f5df3bc841aab36f Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Fri, 20 Mar 2009 09:40:19 +0000 Subject: [PATCH] FR [ 2694043 ] Query. first/firstOnly usage best practice https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2694043&group_id=176962 --- base/src/org/compiere/model/MAccountLookup.java | 2 +- base/src/org/compiere/model/MAcctSchemaGL.java | 2 +- base/src/org/compiere/model/MBPartner.java | 3 ++- base/src/org/compiere/model/MLanguage.java | 2 +- base/src/org/compiere/model/MOrgInfo.java | 2 +- base/src/org/compiere/model/MProductCategoryAcct.java | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/base/src/org/compiere/model/MAccountLookup.java b/base/src/org/compiere/model/MAccountLookup.java index 900937d350..38d6a02574 100644 --- a/base/src/org/compiere/model/MAccountLookup.java +++ b/base/src/org/compiere/model/MAccountLookup.java @@ -138,7 +138,7 @@ public final class MAccountLookup extends Lookup implements Serializable String whereClause = "C_ValidCombination_ID=?"; MAccount account = new Query(Env.getCtx(),MAccount.Table_Name,whereClause,null) .setParameters(new Object[]{ID}) - .first(); + .firstOnly(); if(account == null) return false; diff --git a/base/src/org/compiere/model/MAcctSchemaGL.java b/base/src/org/compiere/model/MAcctSchemaGL.java index e3037b7204..f6417816e5 100644 --- a/base/src/org/compiere/model/MAcctSchemaGL.java +++ b/base/src/org/compiere/model/MAcctSchemaGL.java @@ -52,7 +52,7 @@ public class MAcctSchemaGL extends X_C_AcctSchema_GL String whereClause = "C_AcctSchema_ID=?"; return new Query(ctx,MAcctSchemaGL.Table_Name,whereClause,null) .setParameters(new Object[]{C_AcctSchema_ID}) - .first(); + .firstOnly(); } // get /** Logger */ diff --git a/base/src/org/compiere/model/MBPartner.java b/base/src/org/compiere/model/MBPartner.java index 265f01dd1e..c395b34db3 100644 --- a/base/src/org/compiere/model/MBPartner.java +++ b/base/src/org/compiere/model/MBPartner.java @@ -152,7 +152,8 @@ public class MBPartner extends X_C_BPartner { String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?"; MBPartner retValue = new Query(ctx,MBPartner.Table_Name,whereClause.toString(),null) - .setParameters(new Object[]{C_BPartner_ID,Env.getAD_Client_ID(ctx)}).first(); + .setParameters(new Object[]{C_BPartner_ID,Env.getAD_Client_ID(ctx)}) + .firstOnly(); return retValue; } // get diff --git a/base/src/org/compiere/model/MLanguage.java b/base/src/org/compiere/model/MLanguage.java index 8ffb7f9f74..1caa73716c 100644 --- a/base/src/org/compiere/model/MLanguage.java +++ b/base/src/org/compiere/model/MLanguage.java @@ -68,7 +68,7 @@ public class MLanguage extends X_AD_Language { return new Query(ctx, Table_Name, COLUMNNAME_AD_Language+"=?", null) .setParameters(new Object[]{AD_Language}) - .first(); + .firstOnly(); } // get /** diff --git a/base/src/org/compiere/model/MOrgInfo.java b/base/src/org/compiere/model/MOrgInfo.java index 7489878abe..11524f0441 100644 --- a/base/src/org/compiere/model/MOrgInfo.java +++ b/base/src/org/compiere/model/MOrgInfo.java @@ -49,7 +49,7 @@ public class MOrgInfo extends X_AD_OrgInfo } retValue = new Query(ctx, Table_Name, "AD_Org_ID=?", null) .setParameters(new Object[]{AD_Org_ID}) - .first(); + .firstOnly(); if (retValue != null) { s_cache.put(AD_Org_ID, retValue); diff --git a/base/src/org/compiere/model/MProductCategoryAcct.java b/base/src/org/compiere/model/MProductCategoryAcct.java index 8b1b06465d..234d65055c 100644 --- a/base/src/org/compiere/model/MProductCategoryAcct.java +++ b/base/src/org/compiere/model/MProductCategoryAcct.java @@ -53,7 +53,7 @@ public class MProductCategoryAcct extends X_M_Product_Category_Acct final String whereClause = "M_Product_Category_ID=? AND C_AcctSchema_ID=?"; acct = new Query(ctx, Table_Name, whereClause, trxName) .setParameters(new Object[]{M_Product_Category_ID, C_AcctSchema_ID}) - .first(); + .firstOnly(); if (acct != null) { s_cache.put(key, acct);