[ 2214883 ] Remove SQL code and Replace for Query

tested by creating Measurement (Achievement) recs - no error
This commit is contained in:
Redhuan D. Oon 2008-11-02 10:23:27 +00:00
parent 452182ae5b
commit 826f3d86df
1 changed files with 7 additions and 33 deletions

View File

@ -27,6 +27,7 @@ import org.compiere.util.*;
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MAchievement.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $ * @version $Id: MAchievement.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
* red1 - [ 2214883 ] Remove SQL code and Replace for Query
*/ */
public class MAchievement extends X_PA_Achievement public class MAchievement extends X_PA_Achievement
{ {
@ -48,39 +49,12 @@ public class MAchievement extends X_PA_Achievement
*/ */
public static MAchievement[] getOfMeasure (Properties ctx, int PA_Measure_ID) public static MAchievement[] getOfMeasure (Properties ctx, int PA_Measure_ID)
{ {
ArrayList<MAchievement> list = new ArrayList<MAchievement>(); String whereClause ="PA_Measure_ID=? AND IsAchieved='Y'";
String sql = "SELECT * FROM PA_Achievement " List <MAchievement> list = new Query(ctx,MAchievement.Table_Name, whereClause, null)
+ "WHERE PA_Measure_ID=? AND IsAchieved='Y' ORDER BY SeqNo, DateDoc"; .setParameters(new Object[]{PA_Measure_ID}).setOrderBy("SeqNo, DateDoc").list();
PreparedStatement pstmt = null;
try return list.toArray(new MAchievement[list.size()]);
{
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, PA_Measure_ID);
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
list.add (new MAchievement (ctx, rs, null));
rs.close ();
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
s_log.log (Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
//
MAchievement[] retValue = new MAchievement[list.size ()];
list.toArray (retValue);
return retValue;
} // getOfMeasure } // getOfMeasure