From 0da2f340e73671471e04a8c4954bad47239eab08 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Sat, 27 Feb 2010 02:26:04 +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 --- .../org/compiere/model/MProductPricing.java | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/base/src/org/compiere/model/MProductPricing.java b/base/src/org/compiere/model/MProductPricing.java index 6f77e6b9cc..e7093f3e1d 100644 --- a/base/src/org/compiere/model/MProductPricing.java +++ b/base/src/org/compiere/model/MProductPricing.java @@ -20,6 +20,7 @@ import java.math.BigDecimal; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Timestamp; +import java.util.List; import java.util.logging.Level; import org.compiere.util.CLogger; @@ -717,30 +718,14 @@ public class MProductPricing if (m_M_Product_ID == 0) return; // - String sql = "SELECT C_UOM_ID, M_Product_Category_ID FROM M_Product WHERE M_Product_ID=?"; - PreparedStatement pstmt = null; - ResultSet rs = null; - try - { - pstmt = DB.prepareStatement(sql, null); - pstmt.setInt(1, m_M_Product_ID); - rs = pstmt.executeQuery(); - if (rs.next()) - { - m_C_UOM_ID = rs.getInt (1); - m_M_Product_Category_ID = rs.getInt(2); - } - } - catch (Exception e) - { - log.log(Level.SEVERE, sql, e); - } - finally - { - DB.close(rs, pstmt); - rs = null; - pstmt = null; - } + //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 + String whereClause = "M_Product_ID=?"; + MProduct retValue = new Query(Env.getCtx(), I_M_Product.Table_Name, whereClause, null) + .setParameters(m_M_Product_ID) + .first(); + m_C_UOM_ID = retValue.getC_UOM_ID(); + m_M_Product_Category_ID = retValue.getM_Product_Category_ID(); + } // setBaseInfo /**