From 0ff7666a2b6019896438d29f9829cde374039507 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Fri, 5 Mar 2010 18:38:40 +0000 Subject: [PATCH] FR: [ 2214883 ] Remove SQL code and Replace for Query -- JUnit test pending Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883 --- .../org/compiere/model/MCommissionRun.java | 38 +++---------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/base/src/org/compiere/model/MCommissionRun.java b/base/src/org/compiere/model/MCommissionRun.java index 263b514547..c8764d272d 100644 --- a/base/src/org/compiere/model/MCommissionRun.java +++ b/base/src/org/compiere/model/MCommissionRun.java @@ -17,13 +17,10 @@ package org.compiere.model; import java.math.BigDecimal; -import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.util.ArrayList; +import java.util.List; import java.util.Properties; -import java.util.logging.Level; -import org.compiere.util.DB; import org.compiere.util.Env; /** @@ -86,35 +83,10 @@ public class MCommissionRun extends X_C_CommissionRun */ public MCommissionAmt[] getAmts() { - String sql = "SELECT * FROM C_CommissionAmt WHERE C_CommissionRun_ID=?"; - ArrayList list = new ArrayList(); - PreparedStatement pstmt = null; - try - { - pstmt = DB.prepareStatement(sql, get_TrxName()); - pstmt.setInt(1, getC_CommissionRun_ID()); - ResultSet rs = pstmt.executeQuery(); - while (rs.next()) - list.add(new MCommissionAmt(getCtx(), rs, get_TrxName())); - rs.close(); - pstmt.close(); - pstmt = null; - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - try - { - if (pstmt != null) - pstmt.close(); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; - } - + final String whereClause = I_C_CommissionRun.COLUMNNAME_C_CommissionRun_ID+"=?"; + List list = new Query(getCtx(),I_C_CommissionAmt.Table_Name,whereClause,get_TrxName()) + .setParameters(getC_CommissionRun_ID()) + .list(); // Convert MCommissionAmt[] retValue = new MCommissionAmt[list.size()]; list.toArray(retValue);