From 583954e3eb61ca08e472cd10f657d74dae6a2771 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Sun, 28 Feb 2010 02:01:59 +0000 Subject: [PATCH] FR: [ 2214883 ] Remove SQL code and Replace for Query -- JUnit test in next commit (no failures) Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883 --- .../src/org/compiere/model/MProductPrice.java | 36 +++---------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/base/src/org/compiere/model/MProductPrice.java b/base/src/org/compiere/model/MProductPrice.java index 009e231725..c06b52ea89 100644 --- a/base/src/org/compiere/model/MProductPrice.java +++ b/base/src/org/compiere/model/MProductPrice.java @@ -19,6 +19,7 @@ package org.compiere.model; import java.math.BigDecimal; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -51,37 +52,10 @@ public class MProductPrice extends X_M_ProductPrice public static MProductPrice get (Properties ctx, int M_PriceList_Version_ID, int M_Product_ID, String trxName) { - MProductPrice retValue = null; - String sql = "SELECT * FROM M_ProductPrice WHERE M_PriceList_Version_ID=? AND M_Product_ID=?"; - PreparedStatement pstmt = null; - try - { - pstmt = DB.prepareStatement (sql, trxName); - pstmt.setInt (1, M_PriceList_Version_ID); - pstmt.setInt (2, M_Product_ID); - ResultSet rs = pstmt.executeQuery (); - if (rs.next ()) - { - retValue = new MProductPrice (ctx, rs, trxName); - } - rs.close (); - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - s_log.log (Level.SEVERE, sql, e); - } - try - { - if (pstmt != null) - pstmt.close (); - pstmt = null; - } - catch (Exception e) - { - pstmt = null; - } + final String whereClause = MProductPrice.COLUMNNAME_M_PriceList_Version_ID +"=? AND "+MProductPrice.COLUMNNAME_M_Product_ID+"=?"; + MProductPrice retValue = new Query(ctx,I_M_ProductPrice.Table_Name, whereClause, trxName) + .setParameters(M_PriceList_Version_ID, M_Product_ID) + .first(); return retValue; } // get