sql += " " + whereClause;
if (orderClause != null && orderClause.length()>0)
sql += " " + orderClause;
preparedStatement = conn.prepareStatement(sql);
resultSet = preparedStatement.executeQuery();
Account account = null;
while (resultSet.next()) {
account = new Account();
account.setAccountID(resultSet.getString("ACCOUNT_ID"));
if (resultSet.wasNull())
account.setAccountID(null);
account.setTitle(resultSet.getString("TITLE"));
if (resultSet.wasNull())
account.setTitle(null);
account.setAccountType(resultSet.getString("ACCOUNT_TYPE"));
if (resultSet.wasNull())
account.setAccountType(null);
account.setDescription(resultSet.getString("DESCRIPTION"));
if (resultSet.wasNull())
account.setDescription(null);
account.setOpenBalance(new Double(resultSet.getDouble("OPEN_BALANCE")));
if (resultSet.wasNull())
account.setOpenBalance(null);
resultSet.getString("PARENT_ID");
if (!resultSet.wasNull()) {
if (lazyLoad) {
Account parentAccount = new Account();
parentAccount.setAccountID(new String(resultSet.getString("PARENT_ID")));
account.setParentAccount(parentAccount);
}
else {
String accountID = new String(resultSet.getString("PARENT_ID"));
if (!resultSet.wasNull()) {
String accountWhere = "WHERE ACCOUNT_ID = '" + accountID.toString() + "' ";
DAO dao = daoFactory.getDAO("account");
List accountList = dao.load(accountWhere, null, true);
if (accountList.size()>0) {
Account parentAccount = (Account)accountList.get(0);
account.setParentAccount(parentAccount);
}
}
}
}
if (resultSet.wasNull())
account.setParentAccount(null);
account.setActive(new Boolean(resultSet.getBoolean("ACTIVE")));
if (resultSet.wasNull())
account.setActive(null);
Date lastUpdateDate = resultSet.getDate("LAST_UPDATE");
if (!resultSet.wasNull()) {
Calendar lastUpdateCalendar = new GregorianCalendar();
lastUpdateCalendar.setTime(lastUpdateDate);
account.setLastUpdate(lastUpdateCalendar);
}
if (resultSet.wasNull())
account.setLastUpdate(null);
account.setLastUserID(new Integer(resultSet.getInt("LAST_USER_ID")));
if (resultSet.wasNull())
account.setLastUserID(null);
if (!lazyLoad) {
DAO dao = daoFactory.getDAO("account");
List accountList = dao.load("WHERE PARENT_ID = '" + account.getAccountID() + "'",null,true);
Account childAccount = null;
for (int i=0; i<accountList.size(); i++) {
childAccount = (Account)accountList.get(i);
childAccount.setParentAccount(account);
}
account.setAccountList(accountList);
}
retVal.add(account);