MCash.getOfCash - db connection fix

This commit is contained in:
teo_sarca 2008-05-30 15:12:58 +00:00
parent 5d34128328
commit 84e2f1855b
1 changed files with 10 additions and 34 deletions

View File

@ -24,6 +24,7 @@ import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
@ -130,43 +131,18 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
*/ */
public static MAllocationHdr[] getOfCash (Properties ctx, int C_Cash_ID, String trxName) public static MAllocationHdr[] getOfCash (Properties ctx, int C_Cash_ID, String trxName)
{ {
String sql = "SELECT a.C_AllocationHdr_ID FROM C_Cash c " String whereClause = "IsActive='Y'"
+ " INNER JOIN C_Cashline cl ON (c.C_Cash_ID= cl.C_Cash_ID) " + " AND EXISTS (SELECT 1 FROM C_CashLine cl, C_AllocationLine al "
+ " INNER JOIN C_AllocationLine al ON (al.C_Cashline_ID=cl.C_Cashline_ID) " + "where cl.C_Cash_ID=? and al.C_CashLine_ID=cl.C_CashLine_ID "
+ " INNER JOIN C_AllocationHdr a ON(al.C_AllocationHdr_ID=a.C_AllocationHdr_ID) " + "and C_AllocationHdr.C_AllocationHdr_ID=al.C_AllocationHdr_ID)";
+ " WHERE c.C_Cash_ID=? GROUP BY a.C_AllocationHdr_ID"; Query query = MTable.get(ctx, MAllocationHdr.Table_ID)
.createQuery(whereClause, trxName);
ArrayList<MAllocationHdr> list = new ArrayList<MAllocationHdr>(); query.setParameters(new Object[]{C_Cash_ID});
PreparedStatement pstmt = null; List<MAllocationHdr> list = query.list();
try
{
pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, C_Cash_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add (new MAllocationHdr(ctx, rs.getInt(1), trxName));
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
s_log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
MAllocationHdr[] retValue = new MAllocationHdr[list.size()]; MAllocationHdr[] retValue = new MAllocationHdr[list.size()];
list.toArray(retValue); list.toArray(retValue);
return retValue; return retValue;
} // getOfInvoice } // getOfCash
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger(MAllocationHdr.class); private static CLogger s_log = CLogger.getCLogger(MAllocationHdr.class);