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-18 23:02:06 +00:00
parent 424c34fe13
commit 8338c1f05c
1 changed files with 5 additions and 36 deletions

View File

@ -16,19 +16,16 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.model; package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB;
/** /**
* Currency Account Model * Currency Account Model
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: MCurrencyAcct.java,v 1.3 2006/07/30 00:58:38 jjanke Exp $ * @version $Id: MCurrencyAcct.java,v 1.3 2006/07/30 00:58:38 jjanke Exp $
* @author red1 - FR: [ 2214883 ] Remove SQL code and Replace for Query
*/ */
public class MCurrencyAcct extends X_C_Currency_Acct public class MCurrencyAcct extends X_C_Currency_Acct
{ {
@ -47,38 +44,10 @@ public class MCurrencyAcct extends X_C_Currency_Acct
*/ */
public static MCurrencyAcct get (MAcctSchemaDefault as, int C_Currency_ID) public static MCurrencyAcct get (MAcctSchemaDefault as, int C_Currency_ID)
{ {
MCurrencyAcct retValue = null; final String whereClause = I_C_Currency_Acct.COLUMNNAME_C_AcctSchema_ID+"=? AND "+I_C_Currency_Acct.COLUMNNAME_C_Currency_ID+"=?";
String sql = "SELECT * FROM C_Currency_Acct " MCurrencyAcct retValue = new Query(as.getCtx(),I_C_Currency_Acct.Table_Name,whereClause,null)
+ "WHERE C_AcctSchema_ID=? AND C_Currency_ID=?"; .setParameters(as.getC_AcctSchema_ID(),C_Currency_ID)
PreparedStatement pstmt = null; .first();
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, as.getC_AcctSchema_ID());
pstmt.setInt(2, C_Currency_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
retValue = new MCurrencyAcct (as.getCtx(), rs, null);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, "get", e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
return retValue; return retValue;
} // get } // get