From a9ec807b686d5cab5f02218057af39c85a56894a Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Tue, 4 Nov 2008 15:13:00 +0000 Subject: [PATCH] FR: [ 2214883 ] Remove SQL code and Replace for Query - 1 method only --- base/src/org/compiere/model/MLot.java | 28 +++++++-------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/base/src/org/compiere/model/MLot.java b/base/src/org/compiere/model/MLot.java index 585b783659..9c87cd24fe 100644 --- a/base/src/org/compiere/model/MLot.java +++ b/base/src/org/compiere/model/MLot.java @@ -20,6 +20,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -32,6 +33,7 @@ import org.compiere.util.KeyNamePair; * * @author Jorg Janke * @version $Id: MLot.java,v 1.3 2006/07/30 00:51:02 jjanke Exp $ + * FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 */ public class MLot extends X_M_Lot { @@ -47,27 +49,11 @@ public class MLot extends X_M_Lot */ public static MLot[] getProductLots (Properties ctx, int M_Product_ID, String trxName) { - String sql = "SELECT * FROM M_Lot WHERE M_Product_ID=?"; - ArrayList list = new ArrayList(); - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement (sql, trxName); - pstmt.setInt (1, M_Product_ID); - rs = pstmt.executeQuery (); - while (rs.next ()) - list.add (new MLot (ctx, rs, trxName)); - } - catch (SQLException ex) - { - s_log.log(Level.SEVERE, sql, ex); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } + //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 + String whereClause = "M_Product_ID=?"; + List list = new Query(ctx, MLot.Table_Name, whereClause, null) + .setParameters(new Object[]{M_Product_ID}) + .list(); // MLot[] retValue = new MLot[list.size()]; list.toArray(retValue);