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-02-28 04:24:19 +00:00
parent ede3856d8f
commit e80c558107
1 changed files with 12 additions and 36 deletions

View File

@ -98,37 +98,13 @@ public class MBPartner extends X_C_BPartner
public static MBPartner getBPartnerCashTrx (Properties ctx, int AD_Client_ID)
{
MBPartner retValue = null;
String sql = "SELECT * FROM C_BPartner "
+ "WHERE C_BPartner_ID IN (SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo WHERE AD_Client_ID=?)";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = new MBPartner (ctx, rs, null);
else
s_log.log(Level.SEVERE, "Not found for AD_Client_ID=" + AD_Client_ID);
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
final String whereClause = "C_BPartner_ID IN (SELECT C_BPartnerCashTrx_ID FROM AD_ClientInfo WHERE AD_Client_ID=?)";
retValue = new Query(ctx, I_C_BPartner.Table_Name, whereClause, null)
.setParameters(AD_Client_ID)
.first();
if (retValue == null)
s_log.log(Level.SEVERE, "Not found for AD_Client_ID=" + AD_Client_ID);
return retValue;
} // getBPartnerCashTrx
@ -142,9 +118,9 @@ public class MBPartner extends X_C_BPartner
{
if (Value == null || Value.length() == 0)
return null;
String whereClause = "Value=? AND AD_Client_ID=?";
MBPartner retValue = new Query(ctx,MBPartner.Table_Name,whereClause.toString(),null)
.setParameters(new Object[]{Value,Env.getAD_Client_ID(ctx)})
final String whereClause = "Value=? AND AD_Client_ID=?";
MBPartner retValue = new Query(ctx, I_C_BPartner.Table_Name, whereClause.toString(), null)
.setParameters(Value,Env.getAD_Client_ID(ctx))
.firstOnly();
return retValue;
} // get
@ -158,8 +134,8 @@ public class MBPartner extends X_C_BPartner
public static MBPartner get (Properties ctx, int C_BPartner_ID)
{
String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?";
MBPartner retValue = new Query(ctx,MBPartner.Table_Name,whereClause.toString(),null)
.setParameters(new Object[]{C_BPartner_ID,Env.getAD_Client_ID(ctx)})
MBPartner retValue = new Query(ctx,I_C_BPartner.Table_Name,whereClause.toString(),null)
.setParameters(C_BPartner_ID,Env.getAD_Client_ID(ctx))
.firstOnly();
return retValue;
} // get