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 * <b>Warning:</b> Doesn't support POs with more or less than one key
* column. * column.
*/ */
final static StringBuffer SQL = // static StringBuffer SQL = //
new StringBuffer(" SELECT " )// new StringBuffer(" SELECT " )//
.append(" rt.AD_RelationType_ID AS ").append(COLUMNNAME_AD_RelationType_ID) // .append(" rt.AD_RelationType_ID AS ").append(COLUMNNAME_AD_RelationType_ID) //
.append(", rt.Name AS ").append(COLUMNNAME_Name )// .append(", rt.Name AS ").append(COLUMNNAME_Name )//

View File

@ -326,8 +326,8 @@ public class PromotionRule {
* @throws Exception * @throws Exception
*/ */
private static Map<Integer, List<Integer>> findM_Promotion_ID(MOrder order) 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 ") String select = "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)"); + " 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 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 = ?"; 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, private static DistributionSet calculateDistributionQty(MPromotionDistribution distribution,
DistributionSet prevSet, List<Integer> validPromotionLineIDs, Map<Integer, BigDecimal> orderLineQty, List<Integer> orderLineIdList, String trxName) throws Exception { 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") String sql = "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')") + " 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')") + " 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)") + " 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 = ?") + " WHERE M_PromotionLine.M_PromotionLine_ID = ? AND C_OrderLine.C_OrderLine_ID = ?"
.append(" AND M_PromotionLine.IsActive = 'Y'"); + " AND M_PromotionLine.IsActive = 'Y'";
DistributionSet distributionSet = new DistributionSet(); DistributionSet distributionSet = new DistributionSet();
List<Integer>eligibleOrderLineIDs = new ArrayList<Integer>(); List<Integer>eligibleOrderLineIDs = new ArrayList<Integer>();
@ -434,7 +435,7 @@ public class PromotionRule {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
try { try {
stmt = DB.prepareStatement(sql.toString(), trxName); stmt = DB.prepareStatement(sql, trxName);
stmt.setInt(1, distribution.getM_PromotionLine_ID()); stmt.setInt(1, distribution.getM_PromotionLine_ID());
stmt.setInt(2, C_OrderLine_ID); stmt.setInt(2, C_OrderLine_ID);
rs = stmt.executeQuery(); rs = stmt.executeQuery();
@ -544,20 +545,21 @@ public class PromotionRule {
//List<M_PromotionLine_ID> //List<M_PromotionLine_ID>
List<Integer>applicable = new ArrayList<Integer>(); List<Integer>applicable = new ArrayList<Integer>();
MOrderLine[] lines = order.getLines(); 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) { for (MPromotionLine pl : plist) {
boolean match = false; boolean match = false;
if (pl.getM_PromotionGroup_ID() > 0) { 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; PreparedStatement stmt = null;
ResultSet rs = null; ResultSet rs = null;
try { 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(1, pl.getM_PromotionLine_ID());
stmt.setInt(2, order.getC_Order_ID()); stmt.setInt(2, order.getC_Order_ID());
rs = stmt.executeQuery(); rs = stmt.executeQuery();

View File

@ -47,7 +47,7 @@ public class ResetLockedAccount extends SvrProcess {
if (!user.isLocked()) if (!user.isLocked())
throw new AdempiereException("User " + user.getName() + " is not locked"); 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(" WHERE IsLocked='Y' AND AD_Client_ID = ? ")
.append(" AND DateAccountLocked IS NOT NULL ") .append(" AND DateAccountLocked IS NOT NULL ")
.append(" AND AD_User_ID = " + user.getAD_User_ID()); .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_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); 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(" WHERE IsLocked='Y' AND AD_Client_ID IN (0, ?) ")
.append(" AND DateAccountLocked IS NOT NULL"); .append(" AND DateAccountLocked IS NOT NULL");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -57,13 +57,13 @@ public class GridFieldVO implements Serializable
public static String getSQL (Properties ctx) public static String getSQL (Properties ctx)
{ {
// IsActive is part of View // IsActive is part of View
StringBuffer sql; StringBuilder sql;
if (!Env.isBaseLanguage(ctx, "AD_Tab")) 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(" AND AD_Language='" + Env.getAD_Language(ctx) + "'")
.append(" ORDER BY IsDisplayed DESC, SeqNo"); .append(" ORDER BY IsDisplayed DESC, SeqNo");
else 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"); .append(" ORDER BY IsDisplayed DESC, SeqNo");
return sql.toString(); return sql.toString();
} // getSQL } // getSQL

View File

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

View File

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