IDEMPIERE-308 Performance: Replace use of StringBuffer and String concatenation with StringBuilder / Thanks to Richard Morales

This commit is contained in:
Carlos Ruiz 2012-09-19 14:29:42 -05:00
parent 6b2545bf7f
commit aa20175f3e
21 changed files with 199 additions and 194 deletions

View File

@ -63,7 +63,7 @@ public class MRelationType extends X_AD_RelationType implements IZoomProvider {
* <b>Warning:</b> Doesn't support POs with more or less than one key
* column.
*/
final static StringBuffer SQL = //
static StringBuffer SQL = //
new StringBuffer(" SELECT " )//
.append(" rt.AD_RelationType_ID AS ").append(COLUMNNAME_AD_RelationType_ID) //
.append(", rt.Name AS ").append(COLUMNNAME_Name )//

View File

@ -326,8 +326,8 @@ public class PromotionRule {
* @throws Exception
*/
private static Map<Integer, List<Integer>> findM_Promotion_ID(MOrder order) throws Exception {
StringBuffer select = new StringBuffer("SELECT M_Promotion.M_Promotion_ID From M_Promotion Inner Join M_PromotionPreCondition ")
.append(" ON (M_Promotion.M_Promotion_ID = M_PromotionPreCondition.M_Promotion_ID)");
String select = "SELECT M_Promotion.M_Promotion_ID From M_Promotion Inner Join M_PromotionPreCondition "
+ " ON (M_Promotion.M_Promotion_ID = M_PromotionPreCondition.M_Promotion_ID)";
String bpFilter = "M_PromotionPreCondition.C_BPartner_ID = ? OR M_PromotionPreCondition.C_BP_Group_ID = ? OR (M_PromotionPreCondition.C_BPartner_ID IS NULL AND M_PromotionPreCondition.C_BP_Group_ID IS NULL)";
String priceListFilter = "M_PromotionPreCondition.M_PriceList_ID IS NULL OR M_PromotionPreCondition.M_PriceList_ID = ?";
@ -414,12 +414,13 @@ public class PromotionRule {
private static DistributionSet calculateDistributionQty(MPromotionDistribution distribution,
DistributionSet prevSet, List<Integer> validPromotionLineIDs, Map<Integer, BigDecimal> orderLineQty, List<Integer> orderLineIdList, String trxName) throws Exception {
StringBuilder sql = new StringBuilder("SELECT C_OrderLine.C_OrderLine_ID FROM M_PromotionLine")
.append(" INNER JOIN M_PromotionGroup ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID AND M_PromotionGroup.IsActive = 'Y')")
.append(" INNER JOIN M_PromotionGroupLine ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')")
.append(" INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)")
.append(" WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_OrderLine_ID = ?")
.append(" AND M_PromotionLine.IsActive = 'Y'");
String sql = "SELECT C_OrderLine.C_OrderLine_ID FROM M_PromotionLine"
+ " INNER JOIN M_PromotionGroup ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID AND M_PromotionGroup.IsActive = 'Y')"
+ " INNER JOIN M_PromotionGroupLine ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')"
+ " INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)"
+ " WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_OrderLine_ID = ?"
+ " AND M_PromotionLine.IsActive = 'Y'";
DistributionSet distributionSet = new DistributionSet();
List<Integer>eligibleOrderLineIDs = new ArrayList<Integer>();
@ -434,7 +435,7 @@ public class PromotionRule {
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = DB.prepareStatement(sql.toString(), trxName);
stmt = DB.prepareStatement(sql, trxName);
stmt.setInt(1, distribution.getM_PromotionLine_ID());
stmt.setInt(2, C_OrderLine_ID);
rs = stmt.executeQuery();
@ -544,20 +545,21 @@ public class PromotionRule {
//List<M_PromotionLine_ID>
List<Integer>applicable = new ArrayList<Integer>();
MOrderLine[] lines = order.getLines();
String sql = "SELECT DISTINCT C_OrderLine.C_OrderLine_ID FROM M_PromotionGroup INNER JOIN M_PromotionGroupLine"
+ " ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')"
+ " INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)"
+ " INNER JOIN M_PromotionLine ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID)"
+ " WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_Order_ID = ?"
+ " AND M_PromotionLine.IsActive = 'Y'"
+ " AND M_PromotionGroup.IsActive = 'Y'";
for (MPromotionLine pl : plist) {
boolean match = false;
if (pl.getM_PromotionGroup_ID() > 0) {
StringBuilder sql = new StringBuilder("SELECT DISTINCT C_OrderLine.C_OrderLine_ID FROM M_PromotionGroup INNER JOIN M_PromotionGroupLine")
.append(" ON (M_PromotionGroup.M_PromotionGroup_ID = M_PromotionGroupLine.M_PromotionGroup_ID AND M_PromotionGroupLine.IsActive = 'Y')")
.append(" INNER JOIN C_OrderLine ON (M_PromotionGroupLine.M_Product_ID = C_OrderLine.M_Product_ID)")
.append(" INNER JOIN M_PromotionLine ON (M_PromotionLine.M_PromotionGroup_ID = M_PromotionGroup.M_PromotionGroup_ID)")
.append(" WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_Order_ID = ?")
.append(" AND M_PromotionLine.IsActive = 'Y'")
.append(" AND M_PromotionGroup.IsActive = 'Y'");
PreparedStatement stmt = null;
ResultSet rs = null;
try {
stmt = DB.prepareStatement(sql.toString(), order.get_TrxName());
stmt = DB.prepareStatement(sql, order.get_TrxName());
stmt.setInt(1, pl.getM_PromotionLine_ID());
stmt.setInt(2, order.getC_Order_ID());
rs = stmt.executeQuery();

View File

@ -47,7 +47,7 @@ public class ResetLockedAccount extends SvrProcess {
if (!user.isLocked())
throw new AdempiereException("User " + user.getName() + " is not locked");
StringBuffer sql = new StringBuffer ("UPDATE AD_User SET IsLocked = 'N', DateAccountLocked=NULL, FailedLoginCount=0, DateLastLogin=NULL, Updated=SysDate ")
StringBuilder sql = new StringBuilder ("UPDATE AD_User SET IsLocked = 'N', DateAccountLocked=NULL, FailedLoginCount=0, DateLastLogin=NULL, Updated=SysDate ")
.append(" WHERE IsLocked='Y' AND AD_Client_ID = ? ")
.append(" AND DateAccountLocked IS NOT NULL ")
.append(" AND AD_User_ID = " + user.getAD_User_ID());
@ -62,7 +62,7 @@ public class ResetLockedAccount extends SvrProcess {
int MAX_ACCOUNT_LOCK_MINUTES = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_ACCOUNT_LOCK_MINUTES, 0);
int MAX_INACTIVE_PERIOD = MSysConfig.getIntValue(MSysConfig.USER_LOCKING_MAX_INACTIVE_PERIOD_DAY, 0);
StringBuffer sql = new StringBuffer("UPDATE AD_User SET IsLocked = 'N', DateAccountLocked=NULL, FailedLoginCount=0, DateLastLogin=NULL, Updated=SysDate ")
StringBuilder sql = new StringBuilder("UPDATE AD_User SET IsLocked = 'N', DateAccountLocked=NULL, FailedLoginCount=0, DateLastLogin=NULL, Updated=SysDate ")
.append(" WHERE IsLocked='Y' AND AD_Client_ID IN (0, ?) ")
.append(" AND DateAccountLocked IS NOT NULL");

View File

@ -233,23 +233,24 @@ public class ModelInterfaceGenerator
*/
private StringBuffer createColumns(int AD_Table_ID, StringBuffer mandatory) {
StringBuffer sb = new StringBuffer();
StringBuffer sql = new StringBuffer("SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory,") // 1..3
.append(" c.AD_Reference_ID, c.AD_Reference_Value_ID, DefaultValue, SeqNo, ") // 4..7
.append(" c.FieldLength, c.ValueMin, c.ValueMax, c.VFormat, c.Callout, ") // 8..12
.append(" c.Name, c.Description, c.ColumnSQL, c.IsEncrypted, c.IsKey ") // 13..17
.append("FROM AD_Column c ")
.append("WHERE c.AD_Table_ID=?")
String sql = "SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory," // 1..3
+ " c.AD_Reference_ID, c.AD_Reference_Value_ID, DefaultValue, SeqNo, " // 4..7
+ " c.FieldLength, c.ValueMin, c.ValueMax, c.VFormat, c.Callout, " // 8..12
+ " c.Name, c.Description, c.ColumnSQL, c.IsEncrypted, c.IsKey " // 13..17
+ "FROM AD_Column c "
+ "WHERE c.AD_Table_ID=?"
// + " AND c.ColumnName <> 'AD_Client_ID'"
// + " AND c.ColumnName <> 'AD_Org_ID'"
// + " AND c.ColumnName <> 'IsActive'"
// + " AND c.ColumnName NOT LIKE 'Created%'"
// + " AND c.ColumnName NOT LIKE 'Updated%' "
.append(" AND c.IsActive='Y'")
.append(" ORDER BY c.ColumnName");
+ " AND c.IsActive='Y'"
+ " ORDER BY c.ColumnName";
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
@ -289,7 +290,7 @@ public class ModelInterfaceGenerator
}
catch (SQLException e)
{
throw new DBException(e, sql.toString());
throw new DBException(e, sql);
}
finally
{
@ -495,15 +496,15 @@ public class ModelInterfaceGenerator
else if ((DisplayType.Table == displayType || DisplayType.Search == displayType)
&& AD_Reference_ID > 0)
{
StringBuffer sql = new StringBuffer("SELECT c.AD_Reference_ID, c.AD_Reference_Value_ID")
.append(" FROM AD_Ref_Table rt")
.append(" INNER JOIN AD_Column c ON (c.AD_Column_ID=rt.AD_Key)")
.append(" WHERE rt.AD_Reference_ID=?");
String sql = "SELECT c.AD_Reference_ID, c.AD_Reference_Value_ID"
+" FROM AD_Ref_Table rt"
+" INNER JOIN AD_Column c ON (c.AD_Column_ID=rt.AD_Key)"
+" WHERE rt.AD_Reference_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Reference_ID);
rs = pstmt.executeQuery();
if (rs.next())
@ -518,7 +519,7 @@ public class ModelInterfaceGenerator
}
catch (SQLException e)
{
throw new DBException(e, sql.toString());
throw new DBException(e, sql);
}
finally
{
@ -670,17 +671,17 @@ public class ModelInterfaceGenerator
if (AD_Table_ID == 707 && columnName.equals("Account_ID"))
return null;
//
final StringBuffer sql = new StringBuffer("SELECT t.TableName, t.EntityType, ck.AD_Reference_ID")
.append(" FROM AD_Ref_Table rt")
.append(" INNER JOIN AD_Table t ON (t.AD_Table_ID=rt.AD_Table_ID)")
.append(" INNER JOIN AD_Column ck ON (ck.AD_Table_ID=rt.AD_Table_ID AND ck.AD_Column_ID=rt.AD_Key)")
.append(" WHERE rt.AD_Reference_ID=?")
final String sql = "SELECT t.TableName, t.EntityType, ck.AD_Reference_ID"
+" FROM AD_Ref_Table rt"
+" INNER JOIN AD_Table t ON (t.AD_Table_ID=rt.AD_Table_ID)"
+" INNER JOIN AD_Column ck ON (ck.AD_Table_ID=rt.AD_Table_ID AND ck.AD_Column_ID=rt.AD_Key)"
+" WHERE rt.AD_Reference_ID=?"
;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Reference_ID);
rs = pstmt.executeQuery();
if (rs.next())
@ -705,7 +706,7 @@ public class ModelInterfaceGenerator
}
catch (SQLException e)
{
throw new DBException(e, sql.toString());
throw new DBException(e, sql);
}
finally
{

View File

@ -841,8 +841,8 @@ public abstract class Doc
// We have a document Type, but no GL info - search for DocType
if (m_GL_Category_ID == 0)
{
StringBuilder sql = new StringBuilder("SELECT GL_Category_ID FROM C_DocType ")
.append("WHERE AD_Client_ID=? AND DocBaseType=?");
String sql = "SELECT GL_Category_ID FROM C_DocType "
+ "WHERE AD_Client_ID=? AND DocBaseType=?";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
@ -856,19 +856,19 @@ public abstract class Doc
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
}
// Still no GL_Category - get Default GL Category
if (m_GL_Category_ID == 0)
{
StringBuilder sql = new StringBuilder("SELECT GL_Category_ID FROM GL_Category ")
.append("WHERE AD_Client_ID=? ")
.append("ORDER BY IsDefault DESC");
String sql = "SELECT GL_Category_ID FROM GL_Category "
+ "WHERE AD_Client_ID=? "
+ "ORDER BY IsDefault DESC";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, getAD_Client_ID());
ResultSet rsDT = pstmt.executeQuery();
if (rsDT.next())
@ -878,7 +878,7 @@ public abstract class Doc
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
}
//

View File

@ -71,10 +71,11 @@ public class DocLine_Allocation extends DocLine
{
if (m_C_Invoice_ID == 0)
return 0;
StringBuilder sql = new StringBuilder("SELECT C_Currency_ID ")
.append("FROM C_Invoice ")
.append("WHERE C_Invoice_ID=?");
return DB.getSQLValue(null, sql.toString(), m_C_Invoice_ID);
String sql = "SELECT C_Currency_ID "
+ "FROM C_Invoice "
+ "WHERE C_Invoice_ID=?";
return DB.getSQLValue(null, sql, m_C_Invoice_ID);
} // getInvoiceC_Currency_ID
/**

View File

@ -68,19 +68,19 @@ public class DocManager {
private static void fillDocumentsTableArrays() {
if (documentsTableID == null) {
StringBuilder sql = new StringBuilder("SELECT t.AD_Table_ID, t.TableName ")
.append("FROM AD_Table t, AD_Column c ")
.append("WHERE t.AD_Table_ID=c.AD_Table_ID AND ")
.append("c.ColumnName='Posted' AND ")
.append("IsView='N' ")
.append("ORDER BY t.AD_Table_ID");
String sql = "SELECT t.AD_Table_ID, t.TableName " +
"FROM AD_Table t, AD_Column c " +
"WHERE t.AD_Table_ID=c.AD_Table_ID AND " +
"c.ColumnName='Posted' AND " +
"IsView='N' " +
"ORDER BY t.AD_Table_ID";
ArrayList<Integer> tableIDs = new ArrayList<Integer>();
ArrayList<String> tableNames = new ArrayList<String>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next())
{
@ -90,7 +90,7 @@ public class DocManager {
}
catch (SQLException e)
{
throw new DBException(e, sql.toString());
throw new DBException(e, sql);
}
finally
{

View File

@ -96,14 +96,14 @@ public final class DocTax
if (AcctType < 0 || AcctType > 4)
return null;
//
StringBuilder sql = new StringBuilder("SELECT T_Due_Acct, T_Liability_Acct, T_Credit_Acct, T_Receivables_Acct, T_Expense_Acct ")
.append("FROM C_Tax_Acct WHERE C_Tax_ID=? AND C_AcctSchema_ID=?");
String sql = "SELECT T_Due_Acct, T_Liability_Acct, T_Credit_Acct, T_Receivables_Acct, T_Expense_Acct "
+ "FROM C_Tax_Acct WHERE C_Tax_ID=? AND C_AcctSchema_ID=?";
int validCombination_ID = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_C_Tax_ID);
pstmt.setInt(2, as.getC_AcctSchema_ID());
rs = pstmt.executeQuery();
@ -112,7 +112,7 @@ public final class DocTax
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
finally {
DB.close(rs, pstmt);

View File

@ -628,14 +628,14 @@ public class Doc_AllocationHdr extends Doc
// or Doc.ACCTTYPE_PaymentSelect (AP) or V_Prepayment
int accountType = Doc.ACCTTYPE_UnallocatedCash;
//
StringBuilder sql = new StringBuilder("SELECT p.C_BankAccount_ID, d.DocBaseType, p.IsReceipt, p.IsPrepayment ")
.append("FROM C_Payment p INNER JOIN C_DocType d ON (p.C_DocType_ID=d.C_DocType_ID) ")
.append("WHERE C_Payment_ID=?");
String sql = "SELECT p.C_BankAccount_ID, d.DocBaseType, p.IsReceipt, p.IsPrepayment "
+ "FROM C_Payment p INNER JOIN C_DocType d ON (p.C_DocType_ID=d.C_DocType_ID) "
+ "WHERE C_Payment_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString(), getTrxName());
pstmt = DB.prepareStatement (sql, getTrxName());
pstmt.setInt (1, C_Payment_ID);
rs = pstmt.executeQuery ();
if (rs.next ())
@ -655,7 +655,7 @@ public class Doc_AllocationHdr extends Doc
}
catch (Exception e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
finally
{
@ -680,10 +680,11 @@ public class Doc_AllocationHdr extends Doc
*/
private MAccount getCashAcct (MAcctSchema as, int C_CashLine_ID)
{
StringBuilder sql = new StringBuilder("SELECT c.C_CashBook_ID ")
.append("FROM C_Cash c, C_CashLine cl ")
.append("WHERE c.C_Cash_ID=cl.C_Cash_ID AND cl.C_CashLine_ID=?");
setC_CashBook_ID(DB.getSQLValue(null, sql.toString(), C_CashLine_ID));
String sql = "SELECT c.C_CashBook_ID "
+ "FROM C_Cash c, C_CashLine cl "
+ "WHERE c.C_Cash_ID=cl.C_Cash_ID AND cl.C_CashLine_ID=?";
setC_CashBook_ID(DB.getSQLValue(null, sql, C_CashLine_ID));
if (getC_CashBook_ID() <= 0)
{
log.log(Level.SEVERE, "NONE for C_CashLine_ID=" + C_CashLine_ID);
@ -711,10 +712,10 @@ public class Doc_AllocationHdr extends Doc
BigDecimal invoiceSource = null;
BigDecimal invoiceAccounted = null;
//
StringBuffer sql = new StringBuffer("SELECT ")
.append((invoice.isSOTrx()
StringBuilder sql = new StringBuilder("SELECT ")
.append(invoice.isSOTrx()
? "SUM(AmtSourceDr), SUM(AmtAcctDr)" // so
: "SUM(AmtSourceCr), SUM(AmtAcctCr)")) // po
: "SUM(AmtSourceCr), SUM(AmtAcctCr)") // po
.append(" FROM Fact_Acct ")
.append("WHERE AD_Table_ID=318 AND Record_ID=?") // Invoice
.append(" AND C_AcctSchema_ID=?")
@ -856,16 +857,16 @@ public class Doc_AllocationHdr extends Doc
DiscountAccount, discount, WriteOffAccoint, writeOff, isSOTrx);
// Get Source Amounts with account
StringBuilder sql = new StringBuilder("SELECT * ")
.append("FROM Fact_Acct ")
.append("WHERE AD_Table_ID=318 AND Record_ID=?") // Invoice
.append(" AND C_AcctSchema_ID=?")
.append(" AND Line_ID IS NULL"); // header lines like tax or total
String sql = "SELECT * "
+ "FROM Fact_Acct "
+ "WHERE AD_Table_ID=318 AND Record_ID=?" // Invoice
+ " AND C_AcctSchema_ID=?"
+ " AND Line_ID IS NULL"; // header lines like tax or total
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
pstmt = DB.prepareStatement(sql, getTrxName());
pstmt.setInt(1, line.getC_Invoice_ID());
pstmt.setInt(2, as.getC_AcctSchema_ID());
rs = pstmt.executeQuery();
@ -874,7 +875,7 @@ public class Doc_AllocationHdr extends Doc
}
catch (Exception e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
finally {
DB.close(rs, pstmt);

View File

@ -99,14 +99,14 @@ public class Doc_Invoice extends Doc
private DocTax[] loadTaxes()
{
ArrayList<DocTax> list = new ArrayList<DocTax>();
StringBuilder sql = new StringBuilder("SELECT it.C_Tax_ID, t.Name, t.Rate, it.TaxBaseAmt, it.TaxAmt, t.IsSalesTax ")
.append("FROM C_Tax t, C_InvoiceTax it ")
.append("WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Invoice_ID=?");
String sql = "SELECT it.C_Tax_ID, t.Name, t.Rate, it.TaxBaseAmt, it.TaxAmt, t.IsSalesTax "
+ "FROM C_Tax t, C_InvoiceTax it "
+ "WHERE t.C_Tax_ID=it.C_Tax_ID AND it.C_Invoice_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
pstmt = DB.prepareStatement(sql, getTrxName());
pstmt.setInt(1, get_ID());
rs = pstmt.executeQuery();
//
@ -127,7 +127,7 @@ public class Doc_Invoice extends Doc
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
return null;
}
finally {
@ -885,7 +885,7 @@ public class Doc_Invoice extends Doc
if (ci.getC_AcctSchema1_ID() != as.getC_AcctSchema_ID())
return;
StringBuffer sql = new StringBuffer (
StringBuilder sql = new StringBuilder (
"UPDATE M_Product_PO po ")
.append("SET PriceLastInv = ")
// select

View File

@ -164,17 +164,17 @@ public class Doc_Order extends Doc
}
//
ArrayList<DocLine> list = new ArrayList<DocLine>();
StringBuilder sql = new StringBuilder("SELECT * FROM M_RequisitionLine rl ")
.append("WHERE EXISTS (SELECT * FROM C_Order o ")
.append(" INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID) ")
.append("WHERE ol.C_OrderLine_ID=rl.C_OrderLine_ID")
.append(" AND o.C_Order_ID=?) ")
.append("ORDER BY rl.C_OrderLine_ID");
String sql = "SELECT * FROM M_RequisitionLine rl "
+ "WHERE EXISTS (SELECT * FROM C_Order o "
+ " INNER JOIN C_OrderLine ol ON (o.C_Order_ID=ol.C_Order_ID) "
+ "WHERE ol.C_OrderLine_ID=rl.C_OrderLine_ID"
+ " AND o.C_Order_ID=?) "
+ "ORDER BY rl.C_OrderLine_ID";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString(), null);
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, order.getC_Order_ID());
rs = pstmt.executeQuery ();
while (rs.next ())
@ -201,7 +201,7 @@ public class Doc_Order extends Doc
}
catch (Exception e)
{
log.log (Level.SEVERE, sql.toString(), e);
log.log (Level.SEVERE, sql, e);
}
finally
{

View File

@ -82,14 +82,14 @@ public class Doc_Production extends Doc
ArrayList<DocLine> list = new ArrayList<DocLine>();
// Production
// -- ProductionLine - the real level
StringBuilder sqlPL = new StringBuilder("SELECT * FROM M_ProductionLine pl ")
.append("WHERE pl.M_Production_ID=? ")
.append("ORDER BY pl.Line");
String sqlPL = "SELECT * FROM M_ProductionLine pl "
+ "WHERE pl.M_Production_ID=? "
+ "ORDER BY pl.Line";
try
{
PreparedStatement pstmtPL = DB.prepareStatement(sqlPL.toString(), getTrxName());
PreparedStatement pstmtPL = DB.prepareStatement(sqlPL, getTrxName());
pstmtPL.setInt(1,get_ID());
ResultSet rsPL = pstmtPL.executeQuery();
while (rsPL.next())
@ -113,7 +113,7 @@ public class Doc_Production extends Doc
}
catch (Exception ee)
{
log.log(Level.SEVERE, sqlPL.toString(), ee);
log.log(Level.SEVERE, sqlPL, ee);
}
DocLine[] dl = new DocLine[list.size()];

View File

@ -168,16 +168,16 @@ public class Doc_ProjectIssue extends Doc
{
BigDecimal retValue = null;
// Uses PO Date
StringBuilder sql = new StringBuilder("SELECT currencyConvert(ol.PriceActual, o.C_Currency_ID, ?, o.DateOrdered, o.C_ConversionType_ID, ?, ?) ")
.append("FROM C_OrderLine ol")
.append(" INNER JOIN M_InOutLine iol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID)")
.append(" INNER JOIN C_Order o ON (o.C_Order_ID=ol.C_Order_ID) ")
.append("WHERE iol.M_InOutLine_ID=?");
String sql = "SELECT currencyConvert(ol.PriceActual, o.C_Currency_ID, ?, o.DateOrdered, o.C_ConversionType_ID, ?, ?) "
+ "FROM C_OrderLine ol"
+ " INNER JOIN M_InOutLine iol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID)"
+ " INNER JOIN C_Order o ON (o.C_Order_ID=ol.C_Order_ID) "
+ "WHERE iol.M_InOutLine_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), getTrxName());
pstmt = DB.prepareStatement(sql, getTrxName());
pstmt.setInt(1, as.getC_Currency_ID());
pstmt.setInt(2, getAD_Client_ID());
pstmt.setInt(3, getAD_Org_ID());
@ -193,7 +193,7 @@ public class Doc_ProjectIssue extends Doc
}
catch (Exception e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
finally
{
@ -215,13 +215,13 @@ public class Doc_ProjectIssue extends Doc
BigDecimal retValue = Env.ZERO;
BigDecimal qty = Env.ZERO;
StringBuilder sql = new StringBuilder("SELECT ConvertedAmt, Qty FROM S_TimeExpenseLine ")
.append(" WHERE S_TimeExpenseLine.S_TimeExpenseLine_ID = ?");
String sql = "SELECT ConvertedAmt, Qty FROM S_TimeExpenseLine " +
" WHERE S_TimeExpenseLine.S_TimeExpenseLine_ID = ?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString (), getTrxName());
pstmt = DB.prepareStatement (sql, getTrxName());
pstmt.setInt(1, m_issue.getS_TimeExpenseLine_ID());
rs = pstmt.executeQuery();
if (rs.next())
@ -236,7 +236,7 @@ public class Doc_ProjectIssue extends Doc
}
catch (Exception e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
finally
{

View File

@ -497,13 +497,13 @@ public final class FactLine extends X_Fact_Acct
if (M_Locator_ID == 0)
return;
int C_Location_ID = 0;
StringBuilder sql = new StringBuilder("SELECT w.C_Location_ID FROM M_Warehouse w, M_Locator l ")
.append("WHERE w.M_Warehouse_ID=l.M_Warehouse_ID AND l.M_Locator_ID=?");
String sql = "SELECT w.C_Location_ID FROM M_Warehouse w, M_Locator l "
+ "WHERE w.M_Warehouse_ID=l.M_Warehouse_ID AND l.M_Locator_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, M_Locator_ID);
rs = pstmt.executeQuery();
if (rs.next())
@ -511,7 +511,7 @@ public final class FactLine extends X_Fact_Acct
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
return;
}
finally {
@ -994,16 +994,16 @@ public final class FactLine extends X_Fact_Acct
// get Unearned Revenue Acct from BPartner Group
int UnearnedRevenue_Acct = 0;
int new_Account_ID = 0;
StringBuilder sql = new StringBuilder("SELECT ga.UnearnedRevenue_Acct, vc.Account_ID ")
.append("FROM C_BP_Group_Acct ga, C_BPartner p, C_ValidCombination vc ")
.append("WHERE ga.C_BP_Group_ID=p.C_BP_Group_ID")
.append(" AND ga.UnearnedRevenue_Acct=vc.C_ValidCombination_ID")
.append(" AND ga.C_AcctSchema_ID=? AND p.C_BPartner_ID=?");
String sql = "SELECT ga.UnearnedRevenue_Acct, vc.Account_ID "
+ "FROM C_BP_Group_Acct ga, C_BPartner p, C_ValidCombination vc "
+ "WHERE ga.C_BP_Group_ID=p.C_BP_Group_ID"
+ " AND ga.UnearnedRevenue_Acct=vc.C_ValidCombination_ID"
+ " AND ga.C_AcctSchema_ID=? AND p.C_BPartner_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getC_AcctSchema_ID());
pstmt.setInt(2, C_BPartner_ID);
rs = pstmt.executeQuery();
@ -1015,7 +1015,7 @@ public final class FactLine extends X_Fact_Acct
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
finally {
DB.close(rs, pstmt);
@ -1061,7 +1061,7 @@ public final class FactLine extends X_Fact_Acct
{
boolean success = false;
StringBuffer sql = new StringBuffer("SELECT * ")
StringBuilder sql = new StringBuilder("SELECT * ")
.append("FROM Fact_Acct ")
.append("WHERE C_AcctSchema_ID=? AND AD_Table_ID=? AND Record_ID=?")
.append(" AND Line_ID=? AND Account_ID=?");

View File

@ -80,23 +80,23 @@ public class Matcher
{
int counter = 0;
// (a) Direct Matches
StringBuilder sql = new StringBuilder("SELECT m1.AD_Client_ID,m2.AD_Org_ID, ") // 1..2
.append("m1.C_InvoiceLine_ID,m2.M_InOutLine_ID,m1.M_Product_ID, ") // 3..5
.append("m1.DateTrx,m2.DateTrx, m1.Qty, m2.Qty ") // 6..9
.append("FROM M_MatchPO m1, M_MatchPO m2 ")
.append("WHERE m1.C_OrderLine_ID=m2.C_OrderLine_ID")
.append(" AND m1.M_InOutLine_ID IS NULL")
.append(" AND m2.C_InvoiceLine_ID IS NULL")
.append(" AND m1.M_Product_ID=m2.M_Product_ID")
.append(" AND m1.AD_Client_ID=?") // #1
String sql = "SELECT m1.AD_Client_ID,m2.AD_Org_ID, " // 1..2
+ "m1.C_InvoiceLine_ID,m2.M_InOutLine_ID,m1.M_Product_ID, " // 3..5
+ "m1.DateTrx,m2.DateTrx, m1.Qty, m2.Qty " // 6..9
+ "FROM M_MatchPO m1, M_MatchPO m2 "
+ "WHERE m1.C_OrderLine_ID=m2.C_OrderLine_ID"
+ " AND m1.M_InOutLine_ID IS NULL"
+ " AND m2.C_InvoiceLine_ID IS NULL"
+ " AND m1.M_Product_ID=m2.M_Product_ID"
+ " AND m1.AD_Client_ID=?" // #1
// Not existing Inv Matches
.append(" AND NOT EXISTS (SELECT * FROM M_MatchInv mi ")
.append("WHERE mi.C_InvoiceLine_ID=m1.C_InvoiceLine_ID AND mi.M_InOutLine_ID=m2.M_InOutLine_ID)");
+ " AND NOT EXISTS (SELECT * FROM M_MatchInv mi "
+ "WHERE mi.C_InvoiceLine_ID=m1.C_InvoiceLine_ID AND mi.M_InOutLine_ID=m2.M_InOutLine_ID)";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Client_ID);
rs = pstmt.executeQuery();
while (rs.next())

View File

@ -83,18 +83,18 @@ public class ProductInfo
if (m_M_Product_ID == 0)
return;
StringBuilder sql = new StringBuilder("SELECT p.ProductType, pc.Value, ") // 1..2
.append("p.C_RevenueRecognition_ID,p.C_UOM_ID, ") // 3..4
.append("p.AD_Client_ID,p.AD_Org_ID, ") // 5..6
.append("p.IsBOM, p.IsStocked ") // 7..8
.append("FROM M_Product_Category pc")
.append(" INNER JOIN M_Product p ON (pc.M_Product_Category_ID=p.M_Product_Category_ID) ")
.append("WHERE p.M_Product_ID=?"); // #1
String sql = "SELECT p.ProductType, pc.Value, " // 1..2
+ "p.C_RevenueRecognition_ID,p.C_UOM_ID, " // 3..4
+ "p.AD_Client_ID,p.AD_Org_ID, " // 5..6
+ "p.IsBOM, p.IsStocked " // 7..8
+ "FROM M_Product_Category pc"
+ " INNER JOIN M_Product p ON (pc.M_Product_Category_ID=p.M_Product_Category_ID) "
+ "WHERE p.M_Product_ID=?"; // #1
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
rs = pstmt.executeQuery();
if (rs.next())
@ -113,7 +113,7 @@ public class ProductInfo
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
finally {
DB.close(rs, pstmt);
@ -296,9 +296,9 @@ public class ProductInfo
*/
private BigDecimal getPOCost (MAcctSchema as)
{
StringBuilder sql = new StringBuilder("SELECT C_Currency_ID, PriceList,PricePO,PriceLastPO ")
.append("FROM M_Product_PO WHERE M_Product_ID=? ")
.append("ORDER BY IsCurrentVendor DESC");
String sql = "SELECT C_Currency_ID, PriceList,PricePO,PriceLastPO "
+ "FROM M_Product_PO WHERE M_Product_ID=? "
+ "ORDER BY IsCurrentVendor DESC";
int C_Currency_ID = 0;
BigDecimal PriceList = null;
@ -308,7 +308,7 @@ public class ProductInfo
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID);
rs = pstmt.executeQuery();
if (rs.next())
@ -321,7 +321,7 @@ public class ProductInfo
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
finally {
DB.close(rs, pstmt);

View File

@ -115,12 +115,12 @@ public final class ImpFormat
m_AD_Table_ID = AD_Table_ID;
m_tableName = null;
m_tablePK = null;
StringBuilder sql = new StringBuilder("SELECT t.TableName,c.ColumnName ")
.append("FROM AD_Table t INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID AND c.IsKey='Y') ")
.append("WHERE t.AD_Table_ID=?");
String sql = "SELECT t.TableName,c.ColumnName "
+ "FROM AD_Table t INNER JOIN AD_Column c ON (t.AD_Table_ID=c.AD_Table_ID AND c.IsKey='Y') "
+ "WHERE t.AD_Table_ID=?";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
@ -301,14 +301,14 @@ public final class ImpFormat
*/
private static void loadRows (ImpFormat format, int ID)
{
StringBuilder sql = new StringBuilder("SELECT f.SeqNo,c.ColumnName,f.StartNo,f.EndNo,f.DataType,c.FieldLength,") // 1..6
.append("f.DataFormat,f.DecimalPoint,f.DivideBy100,f.ConstantValue,f.Callout ") // 7..11
.append("FROM AD_ImpFormat_Row f,AD_Column c ")
.append("WHERE f.AD_ImpFormat_ID=? AND f.AD_Column_ID=c.AD_Column_ID AND f.IsActive='Y'")
.append("ORDER BY f.SeqNo");
String sql = "SELECT f.SeqNo,c.ColumnName,f.StartNo,f.EndNo,f.DataType,c.FieldLength," // 1..6
+ "f.DataFormat,f.DecimalPoint,f.DivideBy100,f.ConstantValue,f.Callout " // 7..11
+ "FROM AD_ImpFormat_Row f,AD_Column c "
+ "WHERE f.AD_ImpFormat_ID=? AND f.AD_Column_ID=c.AD_Column_ID AND f.IsActive='Y'"
+ "ORDER BY f.SeqNo";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt (1, ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
@ -327,7 +327,7 @@ public final class ImpFormat
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
}
} // loadLines

View File

@ -69,13 +69,13 @@ public class MImpFormat extends X_AD_ImpFormat
public MImpFormatRow[] getRows()
{
ArrayList<MImpFormatRow> list = new ArrayList<MImpFormatRow>();
StringBuilder sql = new StringBuilder("SELECT * FROM AD_ImpFormat_Row ")
.append("WHERE AD_ImpFormat_ID=? ")
.append("ORDER BY SeqNo");
String sql = "SELECT * FROM AD_ImpFormat_Row "
+ "WHERE AD_ImpFormat_ID=? "
+ "ORDER BY SeqNo";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setInt (1, getAD_ImpFormat_ID());
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())

View File

@ -57,13 +57,13 @@ public class GridFieldVO implements Serializable
public static String getSQL (Properties ctx)
{
// IsActive is part of View
StringBuffer sql;
StringBuilder sql;
if (!Env.isBaseLanguage(ctx, "AD_Tab"))
sql = new StringBuffer("SELECT * FROM AD_Field_vt WHERE AD_Tab_ID=?")
sql = new StringBuilder("SELECT * FROM AD_Field_vt WHERE AD_Tab_ID=?")
.append(" AND AD_Language='" + Env.getAD_Language(ctx) + "'")
.append(" ORDER BY IsDisplayed DESC, SeqNo");
else
sql = new StringBuffer("SELECT * FROM AD_Field_v WHERE AD_Tab_ID=?")
sql = new StringBuilder("SELECT * FROM AD_Field_v WHERE AD_Tab_ID=?")
.append(" ORDER BY IsDisplayed DESC, SeqNo");
return sql.toString();
} // getSQL

View File

@ -559,18 +559,18 @@ public class GridWindow implements Serializable
{
if (recalc || m_modelUpdated == null)
{
StringBuilder sql = new StringBuilder("SELECT MAX(w.Updated), MAX(t.Updated), MAX(tt.Updated), MAX(f.Updated), MAX(c.Updated) ")
.append("FROM AD_Window w")
.append(" INNER JOIN AD_Tab t ON (w.AD_Window_ID=t.AD_Window_ID)")
.append(" INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID)")
.append(" INNER JOIN AD_Field f ON (t.AD_Tab_ID=f.AD_Tab_ID)")
.append(" INNER JOIN AD_Column c ON (f.AD_Column_ID=c.AD_Column_ID) ")
.append("WHERE w.AD_Window_ID=?");
String sql = "SELECT MAX(w.Updated), MAX(t.Updated), MAX(tt.Updated), MAX(f.Updated), MAX(c.Updated) "
+ "FROM AD_Window w"
+ " INNER JOIN AD_Tab t ON (w.AD_Window_ID=t.AD_Window_ID)"
+ " INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID)"
+ " INNER JOIN AD_Field f ON (t.AD_Tab_ID=f.AD_Tab_ID)"
+ " INNER JOIN AD_Column c ON (f.AD_Column_ID=c.AD_Column_ID) "
+ "WHERE w.AD_Window_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString(), null);
pstmt = DB.prepareStatement (sql, null);
pstmt.setInt (1, getAD_Window_ID());
rs = pstmt.executeQuery ();
if (rs.next ())
@ -592,7 +592,7 @@ public class GridWindow implements Serializable
}
catch (Exception e)
{
log.log (Level.SEVERE, sql.toString(), e);
log.log (Level.SEVERE, sql, e);
}
finally
{

View File

@ -77,21 +77,21 @@ public class CalloutUser extends CalloutEngine
if (C_BPartner_ID == null || C_BPartner_ID.intValue() == 0)
return "";
StringBuilder sql = new StringBuilder("SELECT p.AD_Language,p.C_PaymentTerm_ID,")
.append (" COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference,")
.append (" p.SO_Description,p.IsDiscountPrinted,")
.append (" p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable,")
.append (" l.C_BPartner_Location_ID,c.AD_User_ID,")
.append (" COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID ")
.append ("FROM C_BPartner p")
.append (" INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)")
.append (" LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID AND l.IsBillTo='Y' AND l.IsActive='Y')")
.append (" LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID) ")
.append ("WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"); // #1
String sql = "SELECT p.AD_Language,p.C_PaymentTerm_ID,"
+ " COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference,"
+ " p.SO_Description,p.IsDiscountPrinted,"
+ " p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable,"
+ " l.C_BPartner_Location_ID,c.AD_User_ID,"
+ " COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID "
+ "FROM C_BPartner p"
+ " INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)"
+ " LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID AND l.IsBillTo='Y' AND l.IsActive='Y')"
+ " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID) "
+ "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, C_BPartner_ID.intValue());
ResultSet rs = pstmt.executeQuery();
//
@ -130,7 +130,7 @@ public class CalloutUser extends CalloutEngine
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql.toString(), e);
log.log(Level.SEVERE, sql, e);
return e.getLocalizedMessage();
}