From d2333e90264943167199ee5e81f589dce7766910 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Tue, 2 Mar 2010 15:38:35 +0000 Subject: [PATCH] Review FR: [ 2214883 ] Remove SQL code and Replace for Query >> to incorporate Best Practice. No unit testing done but compiler tested OK. Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883 --- base/src/org/compiere/model/MAchievement.java | 12 ++++++------ base/src/org/compiere/model/MAlert.java | 8 ++++---- base/src/org/compiere/model/MAllocationHdr.java | 2 +- base/src/org/compiere/model/M_Element.java | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/base/src/org/compiere/model/MAchievement.java b/base/src/org/compiere/model/MAchievement.java index f48b1e9663..8c2a90d2da 100644 --- a/base/src/org/compiere/model/MAchievement.java +++ b/base/src/org/compiere/model/MAchievement.java @@ -33,9 +33,7 @@ import org.compiere.util.Env; */ public class MAchievement extends X_PA_Achievement { - /** - * - */ + private static final long serialVersionUID = -1438593600498523664L; /** @@ -56,9 +54,11 @@ public class MAchievement extends X_PA_Achievement */ public static MAchievement[] getOfMeasure (Properties ctx, int PA_Measure_ID) { - String whereClause ="PA_Measure_ID=? AND IsAchieved='Y'"; - List list = new Query(ctx,MAchievement.Table_Name, whereClause, null) - .setParameters(new Object[]{PA_Measure_ID}).setOrderBy("SeqNo, DateDoc").list(); + final String whereClause ="PA_Measure_ID=? AND IsAchieved='Y'"; + List list = new Query(ctx,I_PA_Achievement.Table_Name, whereClause, null) + .setParameters(PA_Measure_ID) + .setOrderBy("SeqNo, DateDoc") + .list(); MAchievement[] retValue = new MAchievement[list.size ()]; retValue = list.toArray (retValue); diff --git a/base/src/org/compiere/model/MAlert.java b/base/src/org/compiere/model/MAlert.java index 016b2a43e6..f5857dd4b6 100644 --- a/base/src/org/compiere/model/MAlert.java +++ b/base/src/org/compiere/model/MAlert.java @@ -89,8 +89,8 @@ public class MAlert extends X_AD_Alert return m_rules; //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 final String whereClause = "AD_Alert_ID=?"; - List list = new Query(getCtx(), MAlertRule.Table_Name, whereClause, null) - .setParameters(new Object[]{getAD_Alert_ID()}) + List list = new Query(getCtx(), I_AD_AlertRule.Table_Name, whereClause, null) + .setParameters(getAD_Alert_ID()) .setOrderBy("Name, AD_AlertRule_ID") .setOnlyActiveRecords(true) .list() @@ -116,8 +116,8 @@ public class MAlert extends X_AD_Alert return m_recipients; //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 final String whereClause = "AD_Alert_ID=?"; - List list = new Query(getCtx(), MAlertRecipient.Table_Name, whereClause, null) - .setParameters(new Object[]{getAD_Alert_ID()}) + List list = new Query(getCtx(), I_AD_AlertRecipient.Table_Name, whereClause, null) + .setParameters(getAD_Alert_ID()) .setOnlyActiveRecords(true) .list() ; diff --git a/base/src/org/compiere/model/MAllocationHdr.java b/base/src/org/compiere/model/MAllocationHdr.java index ab1c0b0617..23567fa751 100644 --- a/base/src/org/compiere/model/MAllocationHdr.java +++ b/base/src/org/compiere/model/MAllocationHdr.java @@ -416,7 +416,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction + I_C_Invoice.COLUMNNAME_DocStatus + " NOT IN (?,?)"; boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause, get_TrxName()) .setClient_ID() - .setParameters(new Object[]{line.getC_Invoice_ID(), "Y", MInvoice.DOCSTATUS_Voided, MInvoice.DOCSTATUS_Reversed}) + .setParameters(line.getC_Invoice_ID(), "Y", X_C_Invoice.DOCSTATUS_Voided, X_C_Invoice.DOCSTATUS_Reversed) .match(); if(InvoiceIsPaid) throw new AdempiereException("@ValidationError@ @C_Invoice_ID@ @IsPaid@"); diff --git a/base/src/org/compiere/model/M_Element.java b/base/src/org/compiere/model/M_Element.java index c6e7a8ae02..033c2f3ccd 100644 --- a/base/src/org/compiere/model/M_Element.java +++ b/base/src/org/compiere/model/M_Element.java @@ -91,8 +91,8 @@ public class M_Element extends X_AD_Element // // TODO: caching if trxName == null final String whereClause = "UPPER(ColumnName)=?"; - M_Element retValue = new Query(ctx, M_Element.Table_Name, whereClause, trxName) - .setParameters(new Object[]{columnName.toUpperCase()}) + M_Element retValue = new Query(ctx, I_AD_Element.Table_Name, whereClause, trxName) + .setParameters(columnName.toUpperCase()) .firstOnly(); return retValue; } // get