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:
parent
c3805382ae
commit
83154f494f
|
@ -54,9 +54,9 @@ 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)
|
||||||
{
|
{
|
||||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||||
String whereClause = "M_Product_ID=?";
|
final String whereClause = "M_Product_ID=?";
|
||||||
List <MLot> list = new Query(ctx, MLot.Table_Name, whereClause, trxName)
|
List <MLot> list = new Query(ctx, I_M_Lot.Table_Name, whereClause, trxName)
|
||||||
.setParameters(new Object[]{M_Product_ID})
|
.setParameters(M_Product_ID)
|
||||||
.list();
|
.list();
|
||||||
//
|
//
|
||||||
MLot[] retValue = new MLot[list.size()];
|
MLot[] retValue = new MLot[list.size()];
|
||||||
|
@ -70,32 +70,16 @@ public class MLot extends X_M_Lot
|
||||||
* @param M_Product_ID product
|
* @param M_Product_ID product
|
||||||
* @param lot
|
* @param lot
|
||||||
* @param trxName transaction
|
* @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)
|
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;
|
MLot retValue = null;
|
||||||
PreparedStatement pstmt = null;
|
retValue = list.get(list.size()-1); //red1 get last lot
|
||||||
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;
|
|
||||||
}
|
|
||||||
return retValue;
|
return retValue;
|
||||||
} // getProductLot
|
} // getProductLot
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue