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-16 10:04:31 +00:00
parent ac6175e8d7
commit bcea2db3d8
1 changed files with 7 additions and 38 deletions

View File

@ -16,13 +16,10 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.TimeUtil; import org.compiere.util.TimeUtil;
@ -105,48 +102,20 @@ public class MPriceListVersion extends X_M_PriceList_Version
{ {
if (m_pp != null && !refresh) if (m_pp != null && !refresh)
return m_pp; return m_pp;
m_pp = getProductPrice(null); m_pp = getProductPrice();
return m_pp; return m_pp;
} // getProductPrice } // getProductPrice
/** /**
* Get Product Price * Get Product Price
* @param whereClause optional where clause
* @return product price * @return product price
*/ */
public MProductPrice[] getProductPrice (String whereClause) public MProductPrice[] getProductPrice ()
{ {
ArrayList<MProductPrice> list = new ArrayList<MProductPrice>(); final String whereClause = I_M_ProductPrice.COLUMNNAME_M_PriceList_Version_ID+"=?";
String sql = "SELECT * FROM M_ProductPrice WHERE M_PriceList_Version_ID=?"; List<MProductPrice> list = new Query(getCtx(),I_M_ProductPrice.Table_Name,whereClause,get_TrxName())
if (whereClause != null) .setParameters(getM_PriceList_Version_ID())
sql += " " + whereClause; .list();
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql, get_TrxName ());
pstmt.setInt (1, getM_PriceList_Version_ID());
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MProductPrice(getCtx(), rs, get_TrxName()));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
//
MProductPrice[] pp = new MProductPrice[list.size()]; MProductPrice[] pp = new MProductPrice[list.size()];
list.toArray(pp); list.toArray(pp);
return pp; return pp;