FR: [ 2214883 ] Remove SQL code and Replace for Query - 1 method only

This commit is contained in:
Redhuan D. Oon 2008-11-04 15:13:00 +00:00
parent 208eaf65a3
commit a9ec807b68
1 changed files with 7 additions and 21 deletions

View File

@ -20,6 +20,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -32,6 +33,7 @@ import org.compiere.util.KeyNamePair;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MLot.java,v 1.3 2006/07/30 00:51:02 jjanke Exp $ * @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 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) public static MLot[] getProductLots (Properties ctx, int M_Product_ID, String trxName)
{ {
String sql = "SELECT * FROM M_Lot WHERE M_Product_ID=?"; //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
ArrayList<MLot> list = new ArrayList<MLot>(); String whereClause = "M_Product_ID=?";
PreparedStatement pstmt = null; List <MLot> list = new Query(ctx, MLot.Table_Name, whereClause, null)
ResultSet rs = null; .setParameters(new Object[]{M_Product_ID})
try .list();
{
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;
}
// //
MLot[] retValue = new MLot[list.size()]; MLot[] retValue = new MLot[list.size()];
list.toArray(retValue); list.toArray(retValue);