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
This commit is contained in:
Redhuan D. Oon 2010-03-01 06:39:45 +00:00
parent c3805382ae
commit 83154f494f
1 changed files with 9 additions and 25 deletions

View File

@ -54,9 +54,9 @@ public class MLot extends X_M_Lot
public static MLot[] getProductLots (Properties ctx, int M_Product_ID, String trxName)
{
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "M_Product_ID=?";
List <MLot> list = new Query(ctx, MLot.Table_Name, whereClause, trxName)
.setParameters(new Object[]{M_Product_ID})
final String whereClause = "M_Product_ID=?";
List <MLot> list = new Query(ctx, I_M_Lot.Table_Name, whereClause, trxName)
.setParameters(M_Product_ID)
.list();
//
MLot[] retValue = new MLot[list.size()];
@ -70,32 +70,16 @@ public class MLot extends X_M_Lot
* @param M_Product_ID product
* @param lot
* @param trxName transaction
* @return Array of Lots for Product
* @return Array of Lots for Product //red1 -- last Lot
*/
public static MLot getProductLot (Properties ctx, int M_Product_ID, String lot, String trxName)
{
String sql = "SELECT * FROM M_Lot WHERE M_Product_ID=? AND Name=?";
final String whereClause = "M_Product_ID=? AND Name=?";
List <MLot> list = new Query(ctx, I_M_Lot.Table_Name, whereClause, trxName)
.setParameters(M_Product_ID, lot)
.list();
MLot retValue = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql, trxName);
pstmt.setInt (1, M_Product_ID);
pstmt.setString(2, lot);
rs = pstmt.executeQuery ();
while (rs.next ())
retValue = new MLot (ctx, rs, trxName);
}
catch (SQLException ex)
{
s_log.log(Level.SEVERE, sql, ex);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
retValue = list.get(list.size()-1); //red1 get last lot
return retValue;
} // getProductLot