FR: [ 2214883 ] Remove SQL code and Replace for Query

Applying defensive programming approach and ABP.
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883
This commit is contained in:
vpj-cd 2010-02-27 06:12:53 +00:00
parent 998d5c20f5
commit ec4e2f798a
10 changed files with 59 additions and 52 deletions

View File

@ -33,6 +33,8 @@ import org.compiere.util.KeyNamePair;
*/
public class MAcctSchemaDefault extends X_C_AcctSchema_Default
{
/**
*
*/
@ -46,7 +48,7 @@ public class MAcctSchemaDefault extends X_C_AcctSchema_Default
*/
public static MAcctSchemaDefault get (Properties ctx, int C_AcctSchema_ID)
{
String whereClause = "C_AcctSchema_ID=?";
final String whereClause = "C_AcctSchema_ID=?";
return new Query(ctx,I_C_AcctSchema_Default.Table_Name,whereClause,null)
.setParameters(C_AcctSchema_ID)
.firstOnly();

View File

@ -40,6 +40,8 @@ import org.compiere.util.Msg;
*/
public final class MAcctSchemaElement extends X_C_AcctSchema_Element
{
/**
*
*/
@ -61,7 +63,7 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element
s_log.fine("C_AcctSchema_ID=" + as.getC_AcctSchema_ID());
ArrayList<MAcctSchemaElement> list = new ArrayList<MAcctSchemaElement>();
String whereClause = "C_AcctSchema_ID=? AND IsActive=?";
final String whereClause = "C_AcctSchema_ID=? AND IsActive=?";
List<MAcctSchemaElement> elements= new Query(as.getCtx(), I_C_AcctSchema_Element.Table_Name,whereClause,as.get_TrxName())
.setParameters(as.getC_AcctSchema_ID(),"Y")
.setOrderBy("SeqNo")

View File

@ -35,6 +35,8 @@ import org.compiere.util.KeyNamePair;
*/
public class MAcctSchemaGL extends X_C_AcctSchema_GL
{
/**
*
*/
@ -49,7 +51,7 @@ public class MAcctSchemaGL extends X_C_AcctSchema_GL
*/
public static MAcctSchemaGL get (Properties ctx, int C_AcctSchema_ID)
{
String whereClause = "C_AcctSchema_ID=?";
final String whereClause = "C_AcctSchema_ID=?";
return new Query(ctx,I_C_AcctSchema_GL.Table_Name,whereClause,null)
.setParameters(C_AcctSchema_ID)
.firstOnly();

View File

@ -40,6 +40,7 @@ import org.compiere.util.Env;
*/
public class MPInstance extends X_AD_PInstance
{
/**
*
*/
@ -126,7 +127,7 @@ public class MPInstance extends X_AD_PInstance
if (m_parameters != null)
return m_parameters;
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "AD_PInstance_ID=?";
final String whereClause = "AD_PInstance_ID=?";
List <MPInstancePara> list = new Query(getCtx(), I_AD_PInstance_Para.Table_Name, whereClause, null) // @TODO: Review implications of using transaction
.setParameters(getAD_PInstance_ID())
.list();

View File

@ -30,6 +30,7 @@ import org.compiere.util.Env;
*/
public class MPaySelection extends X_C_PaySelection
{
/**
*
*/
@ -84,7 +85,7 @@ public class MPaySelection extends X_C_PaySelection
return m_lines;
}
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "C_PaySelection_ID=?";
final String whereClause = "C_PaySelection_ID=?";
List <MPaySelectionLine> list = new Query(getCtx(), I_C_PaySelectionLine.Table_Name, whereClause, get_TrxName())
.setParameters(getC_PaySelection_ID())
.setOrderBy("Line")

View File

@ -77,6 +77,8 @@ import org.compiere.util.ValueNamePair;
public final class MPayment extends X_C_Payment
implements DocAction, ProcessCall
{
/**
*
*/
@ -92,7 +94,7 @@ public final class MPayment extends X_C_Payment
public static MPayment[] getOfBPartner (Properties ctx, int C_BPartner_ID, String trxName)
{
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "C_BPartner_ID=?";
final String whereClause = "C_BPartner_ID=?";
List <MPayment> list = new Query(ctx, I_C_Payment.Table_Name, whereClause, trxName)
.setParameters(C_BPartner_ID)
.list();

View File

@ -20,7 +20,6 @@ import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.List;
import java.util.logging.Level;
import org.compiere.util.CLogger;
@ -719,7 +718,7 @@ public class MProductPricing
return;
//
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "M_Product_ID=?";
final String whereClause = "M_Product_ID=?";
MProduct retValue = new Query(Env.getCtx(), I_M_Product.Table_Name, whereClause, null)
.setParameters(m_M_Product_ID)
.first();

View File

@ -16,11 +16,8 @@
*****************************************************************************/
package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -36,6 +33,7 @@ import org.compiere.util.Env;
*/
public class MProject extends X_C_Project
{
/**
*
*/
@ -206,7 +204,7 @@ public class MProject extends X_C_Project
public MProjectLine[] getLines()
{
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "C_Project_ID=?";
final String whereClause = "C_Project_ID=?";
List <MProjectLine> list = new Query(getCtx(), I_C_ProjectLine.Table_Name, whereClause, get_TrxName())
.setParameters(getC_Project_ID())
.setOrderBy("Line")

View File

@ -18,10 +18,8 @@ package org.compiere.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
@ -40,6 +38,7 @@ import org.compiere.util.Env;
*/
public class MRequestType extends X_R_RequestType
{
/**
*
*/
@ -78,7 +77,7 @@ public class MRequestType extends X_R_RequestType
int AD_Client_ID = Env.getAD_Client_ID(ctx);
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "AD_Client_ID IN (0," + AD_Client_ID + ")";
final String whereClause = "AD_Client_ID IN (0," + AD_Client_ID + ")";
MRequestType retValue = new Query(ctx, I_R_RequestType.Table_Name, whereClause, null)
.setOrderBy("IsDefault DESC, AD_Client_ID DESC")
.first();

View File

@ -33,10 +33,11 @@ import org.compiere.util.Msg;
*/
public class M_Element extends X_AD_Element
{
/**
*
*/
private static final long serialVersionUID = -7426812810619889250L;
private static final long serialVersionUID = -6644398794862560030L;
/**
* Get case sensitive Column Name
@ -107,7 +108,7 @@ public class M_Element extends X_AD_Element
{
if (AD_Column_ID ==0)
return null;
String whereClause = "EXISTS (SELECT 1 FROM AD_Column c "
final String whereClause = "EXISTS (SELECT 1 FROM AD_Column c "
+ "WHERE c.AD_Element_ID=AD_Element.AD_Element_ID AND c.AD_Column_ID=?)";
M_Element retValue = new Query(ctx, Table_Name, whereClause, trxName)
.setParameters(AD_Column_ID)