package StockTradeServices;
import Framework.Array_Of_ListElement;
import Framework.Constants;
import Framework.ErrorMgr;
import Framework.IntegerData;
import Framework.ListElement;
import Framework.Log;
import Framework.ParameterHolder;
import Framework.RuntimeProperties;
import Framework.ServiceObject;
import Framework.ServiceObjectContext;
import Framework.StringUtils;
import Framework.TextData;
import Framework.TextNullable;
import GenericDBMS.ArrayRowMapper;
import GenericDBMS.BeanRowMapper;
import GenericDBMS.DBConnectionManager;
import GenericDBMS.ResultSetHelper;
import StockTradeBusinessClasses.Array_Of_Customer;
import StockTradeBusinessClasses.Array_Of_Holding;
import StockTradeBusinessClasses.Customer;
import StockTradeBusinessClasses.Holding;
import StockTradeServices.InvalidTradeException;
import StockTradeServices.NoSuchCustomerException;
import StockTradeServices.NoSuchHoldingException;
import StockTradeServices.interfaces.ICustomerMgr;
import java.io.Serializable;
import java.lang.Cloneable;
import java.lang.String;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCountCallbackHandler;
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
/**
* CustomerMgr<p>
* <p>
* @author Generated from Forte
* @since 24-Aug-2010
*/
@RuntimeProperties(isDistributed=true, isAnchored=true, isShared=false, isTransactional=false)
@ServiceObject(name="CustomerSO", visibility=ServiceObject.Visibility.ENVIRONMENT, dialogDuration=ServiceObject.DialogDuration.MESSAGE, failover=false, loadBalanced=true)
@SuppressWarnings("serial")
public class CustomerMgr
implements Cloneable, Serializable, ICustomerMgr
{
// ----------
// Attributes
// ----------
private Array_Of_Customer<Customer> customerList;
private Array_Of_ListElement<ListElement> stockNameList;
// ------------
// Constructors
// ------------
public CustomerMgr() {
// Explicitly call the superclass constructor to prevent the implicit call
super();
this.customerList = new Array_Of_Customer<Customer>();
this.setUp();
this.stockNameList = new Array_Of_ListElement<ListElement>();
this.setupStockNameList();
}
/**
* A dummy constructor used to instantiate a "blank" object. This is used for anchored objects, Spring beans and their
* superclasses, but should not be expected to create a valid CustomerMgr.
*/
public CustomerMgr(ServiceObjectContext pContext) {
}
// ----------------------
// Accessors and Mutators
// ----------------------
/**
* Getter for the attribute StockNameList
*/
public Array_Of_ListElement<ListElement> getStockNameList() {
return this.stockNameList;
}
// -------
// Methods
// -------
/**
* decrementHolding<p>
* Import code for DecrementHolding method - CustomerMgr class<br>
* Method does ff:<br>
* Declare a variable of type Customer.<br>
* Declare a variable of type Holding.<br>
* Call the GetCustomer method to get the Customer with the given name.<br>
* Call the GetHolding method to get the Holding for the Customer.<br>
* If a Holding is found, and has more shares than pQuantity:<br>
* decrement the quantity of the Holding by pQuantity.<br>
* If a Holding is found, and has the same quantity as pQuantity:<br>
* delete the Holding from Customer�s HoldingList, using the DeleteRow.<br>
* If a Holding is found, but has an insufficient quantity to decrement:<br>
* raise an InvalidTradeException.<br>
* If a Holding is not found (NoSuchHoldingException is caught):<br>
* code an exception handler and raise an InvalidTradeException.<br>
* <p>
* @param pCustomerName Type: TextData
* @param pStockName Type: String
* @param pQuantity Type: int
* @param pPrice Type: float
*/
public void decrementHolding(TextData pCustomerName, String pStockName, int pQuantity, float pPrice) {
// TODO [129,Info]: Copy of parameter pCustomerName has been skipped because this method is on a service class for StockTradeServices.CustomerSO
try {
Customer oneCustomer = null;
Holding custHolding = null;
float incomeFromStock = pQuantity*pPrice;
oneCustomer = this.getCustomer(pCustomerName);
//custHolding = self.GetHolding(pCustomer=oneCustomer,
// pGetHoldStockName=pStockName);
custHolding = this.SQLSelectHolding(pCustomerName, pStockName);
if (custHolding.getQuantity() > pQuantity) {
custHolding.setQuantity(custHolding.getQuantity()-pQuantity);
oneCustomer.setCashBalance(oneCustomer.getCashBalance()+incomeFromStock);
this.SQLUpdateHolding(custHolding);
this.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());
}
else if (custHolding.getQuantity() == pQuantity) {
this.SQLDeleteHolding(custHolding);
//oneCustomer.HoldingList.DeleteRow(object=custHolding);
oneCustomer.setCashBalance(oneCustomer.getCashBalance()+incomeFromStock);
this.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());
}
else if (custHolding.getQuantity() < pQuantity) {
InvalidTradeException badOrder = new InvalidTradeException();
badOrder.setWithParams(Constants.SP_ER_ERROR, "Customer %1 does not own enough stock to place SELL Order", pCustomerName);
ErrorMgr.addError(badOrder);
throw badOrder;
}
}
catch (NoSuchHoldingException noHolding) {
InvalidTradeException badOrder = new InvalidTradeException();
badOrder.setWithParams(Constants.SP_ER_ERROR, "Customer %1 does not own this stock and cannot place SELL Order", pCustomerName);
ErrorMgr.addError(badOrder);
throw badOrder;
}
}
/**
* dumpStats<p>
* <p>
*/
public void dumpStats() {
String title1 = null;
TextData title2 = null;
TextNullable title3 = null;
int numCustomers = 0;
IntegerData numStocks = null;
double totalValue = 0;
DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
// -- =============== Original SQL ===============
// select
// 'Customers',
// count(distinct CustomerName),
// 'Stocks',
// count(distinct StockName),
// 'Total value',
// sum(Price*Quantity)
// into
// :title1,
// :numCustomers,
// :title2,
// :numStocks,
// :title3,
// :totalValue
// from Holding
// on session DBConnection
// -- ============================================
String qq_SQL = "select " +
"'Customers', " +
"count(distinct CustomerName), " +
"'Stocks', " +
"count(distinct StockName), " +
"'Total value', " +
"sum(Price*Quantity) " +
"from Holding ";
final ParameterHolder qqh_title1 = new ParameterHolder(title1);
final ParameterHolder qqh_numCustomers = new ParameterHolder(numCustomers);
final ParameterHolder qqh_title2 = new ParameterHolder(title2);
final ParameterHolder qqh_numStocks = new ParameterHolder(numStocks);
final ParameterHolder qqh_title3 = new ParameterHolder(title3);
final ParameterHolder qqh_totalValue = new ParameterHolder(totalValue);
RowCountCallbackHandler qq_RowCounter = new RowCountCallbackHandler() {
protected void processRow(ResultSet pResultSet, int pRow) throws SQLException {
if (pRow >= 1) {
throw new IncorrectResultSizeDataAccessException(1, pRow+1);
}
ResultSetHelper helper = new ResultSetHelper(pResultSet);
qqh_title1.setObject(helper.getString(1));
qqh_numCustomers.setInt(helper.getInt(2));
qqh_title2.setObject(helper.getTextData(3));
qqh_numStocks.setObject(helper.getIntegerData(4));
qqh_title3.setObject(helper.getTextNullable(5));
qqh_totalValue.setDouble(helper.getDouble(6));
}
};
dBConnection.getTemplate().query(qq_SQL, qq_RowCounter);
title1 = (String)qqh_title1.getObject();
numCustomers = qqh_numCustomers.getInt();
title2 = (TextData)qqh_title2.getObject();
numStocks = (IntegerData)qqh_numStocks.getObject();
title3 = (TextNullable)qqh_title3.getObject();
totalValue = qqh_totalValue.getDouble();
TextData aMsg = new TextData();
aMsg.concat(title1).concat(":").concat(numCustomers).concat(", ").concat(title2).concat(":").concat(numStocks).concat(", ").concat(title3).concat(totalValue);
Log.standardLog().info(aMsg);
}
/**
* getCustomer<p>
* for row in self.CustomerList do<br>
* if (pGetCustCustomerName.isequal(source=row.CustomerName, ignorecase=TRUE)) then<br>
* return row;<br>
* end if;<br>
* end for;<br>
* //return NIL;<br>
* noSuchCust : NoSuchCustomerException = new;<br>
* noSuchCust.SetWithParams(severity = SP_ER_ERROR,<br>
* message = 'Customer %1 does not exist',<br>
* param1 = pGetCustCustomerName);<br>
* task.ErrorMgr.AddError(error=noSuchCust);<br>
* raise noSuchCust;<br>
* self.DumpStats();<br>
* <p>
* @param pGetCustCustomerName Type: TextData
* @return Customer
*/
public Customer getCustomer(TextData pGetCustCustomerName) {
// TODO [129,Info]: Copy of parameter pGetCustCustomerName has been skipped because this method is on a service class for StockTradeServices.CustomerSO
Customer aCustomer = this.SQLSelectCustomer(pGetCustCustomerName);
aCustomer.setHoldingList(this.SQLSelectHoldingList(pGetCustCustomerName));
return aCustomer;
}
/**
* getHolding<p>
* <p>
* @param pCustomer Type: Customer
* @param pGetHoldStockName Type: String
* @return Holding
*/
public Holding getHolding(Customer pCustomer, String pGetHoldStockName) {
Array_Of_Holding<Holding> qq_localVector = pCustomer.getHoldingList();
if (qq_localVector != null) {
for (Holding row : qq_localVector) {
if (StringUtils.equals(row.getStockName(), pGetHoldStockName)) {
return row;
}
}
}
NoSuchHoldingException noHolding = new NoSuchHoldingException();
noHolding.setWithParams(Constants.SP_ER_ERROR, "Customer %1 does not own this stock", pCustomer.getCustomerName());
ErrorMgr.addError(noHolding);
throw noHolding;
}
// Method GetStockNameList() : Framework.Array of Framework.ListElement skipped because it is replaced by accessor / mutator.
/**
* incrementHolding<p>
* Import code for IncrementHolding method - CustomerMgr class<br>
* Method does ff:<br>
* Declare a variable of type Customer.<br>
* Declare a variable of type Holding.<br>
* Call the GetCustomer method to get the Customer with the given name.<br>
* Call the GetHolding method to get the Holding for the Customer.<br>
* If a Holding is found:<br>
* increment the quantity of the Holding by the pQuantity parameter.<br>
* If a Holding is not found:<br>
* implies NoSuchHoldingException is raised in the GetHolding method.<br>
* Code an exception handler.<br>
* Create a new Holding object.<br>
* Fill in its values based on the method parameters.<br>
* Add it to the Customer�s HoldingList, using the AppendRow method.<br>
* <p>
* @param pCustomerName Type: TextData
* @param pStockName Type: String
* @param pQuantity Type: int
* @param pPrice Type: float
*/
public void incrementHolding(TextData pCustomerName, String pStockName, int pQuantity, float pPrice) {
// TODO [129,Info]: Copy of parameter pCustomerName has been skipped because this method is on a service class for StockTradeServices.CustomerSO
Customer oneCustomer = null;
Holding custHolding = null;
float costOfStock = pQuantity*pPrice;
oneCustomer = this.getCustomer(pCustomerName);
if (oneCustomer.getCashBalance() > costOfStock) {
try {
oneCustomer.setCashBalance(oneCustomer.getCashBalance()-costOfStock);
// custHolding = self.GetHolding(pCustomer=oneCustomer,pGetHoldStockName=pStockName);
custHolding = this.SQLSelectHolding(pCustomerName, pStockName);
custHolding.setQuantity(custHolding.getQuantity()+pQuantity);
this.SQLUpdateHolding(custHolding);
this.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());
}
catch (NoSuchHoldingException noHolding) {
Holding newHolding = new Holding();
newHolding.setCustomerName(pCustomerName);
newHolding.setPrice(pPrice);
newHolding.setQuantity(pQuantity);
newHolding.setStockName(pStockName);
this.SQLInsertHolding(newHolding);
this.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());
// oneCustomer.HoldingList.AppendRow(object=newHolding);
}
}
else {
InvalidTradeException badOrder = new InvalidTradeException();
badOrder.setWithParams(Constants.SP_ER_ERROR, "Customer %1 doesn't have enough cash to BUY stock", pCustomerName);
ErrorMgr.addError(badOrder);
throw badOrder;
}
}
/**
* setUp<p>
* Code to populate CustomerList array<br>
* <p>
*/
private void setUp() {
this.customerList.set(0, new Customer());
this.customerList.get(0).getCustomerName().setValue( "Chris" );
this.customerList.get(0).setAddress("123 4th Ave.\n San Francisco\nCA 94403");
this.customerList.get(0).setPhoneNumber("5104268845");
this.customerList.get(0).setCashBalance(45000f);
Holding holding1 = new Holding();
holding1.setStockName("Happy Duck");
holding1.setQuantity(100);
holding1.setPrice(120f);
this.customerList.get(0).getHoldingList().add(holding1);
Holding holding2 = new Holding();
holding2.setStockName("Coarse Light");
holding2.setQuantity(240);
holding2.setPrice(50f);
this.customerList.get(0).getHoldingList().add(holding2);
Holding holding3 = new Holding();
holding3.setStockName("Boston Quicken");
holding3.setQuantity(50);
holding3.setPrice(50f);
this.customerList.get(0).getHoldingList().add(holding3);
this.customerList.set(1, new Customer());
this.customerList.get(1).getCustomerName().setValue( "Natasha" );
this.customerList.get(1).setAddress("222 44th Ave.\nSan Diego\nCA 90210");
this.customerList.get(1).setPhoneNumber("3335551234");
this.customerList.get(1).setCashBalance(8000f);
Holding holding4 = new Holding();
holding4.setStockName("Boston Quicken");
holding4.setQuantity(10);
holding4.setPrice(120f);
this.customerList.get(1).getHoldingList().add(holding4);
Holding holding5 = new Holding();
holding5.setStockName("Giorgio Osmondi");
holding5.setQuantity(200);
holding5.setPrice(30f);
this.customerList.get(1).getHoldingList().add(holding5);
Holding holding6 = new Holding();
holding6.setStockName("MacDonna");
holding6.setQuantity(100);
holding6.setPrice(50f);
this.customerList.get(1).getHoldingList().add(holding6);
this.customerList.set(2, new Customer());
this.customerList.get(2).getCustomerName().setValue( "Bill" );
this.customerList.get(2).setAddress("2555 Alma St. #3\nPalo Alto\nCA 90011");
this.customerList.get(2).setPhoneNumber("4155556666");
this.customerList.get(2).setCashBalance(10000f);
Holding holding7 = new Holding();
holding7.setStockName("Paco Bella");
holding7.setQuantity(100);
holding7.setPrice(120f);
this.customerList.get(2).getHoldingList().add(holding7);
Holding holding8 = new Holding();
holding8.setStockName("Coarse Light");
holding8.setQuantity(100);
holding8.setPrice(30f);
this.customerList.get(2).getHoldingList().add(holding8);
Holding holding9 = new Holding();
holding9.setStockName("MacDonna");
holding9.setQuantity(100);
holding9.setPrice(50f);
this.customerList.get(2).getHoldingList().add(holding9);
}
/**
* setupStockNameList<p>
* self.StockNameList[1] = new;<br>
* self.StockNameList[1].TextValue.Setvalue('MacDonna');<br>
* self.StockNameList[2] = new;<br>
* self.StockNameList[2].TextValue.Setvalue('Boston Quicken');<br>
* self.StockNameList[3] = new;<br>
* self.StockNameList[3].TextValue.Setvalue('Giorgio Osmondi');<br>
* self.StockNameList[4] = new;<br>
* self.StockNameList[4].TextValue.Setvalue('Microshift');<br>
* self.StockNameList[5] = new;<br>
* self.StockNameList[5].TextValue.Setvalue('Paco Bella');<br>
* self.StockNameList[6] = new;<br>
* self.StockNameList[6].TextValue.Setvalue('Happy Duck');<br>
* self.StockNameList[7] = new;<br>
* self.StockNameList[7].TextValue.Setvalue('Coarse Light');<br>
* self.StockNameList[8] = new;<br>
* self.StockNameList[8].TextValue.Setvalue('Forte');<br>
* <p>
*/
private void setupStockNameList() {
DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
ResultSet qq_rs = null;
PreparedStatement qq_cmd = null;
String qq_SQL = null;
try {
// -- =============== Original SQL ===============
// select StockName from Stock
// on session DBConnection
// -- ============================================
qq_SQL = "select StockName from Stock ";
qq_cmd = dBConnection.getPreparedStatement(qq_SQL);
qq_rs = qq_cmd.executeQuery();
ResultSetHelper qq_rsHelper = new ResultSetHelper(qq_rs);
while (qq_rsHelper.next()) {
TextData temp = qq_rsHelper.getTextData(1);
ListElement row = new ListElement();
row.getTextValue().setValue( temp.getValue() );
this.stockNameList.add(row);
}
}
catch (SQLException qq_error) {
throw new SQLErrorCodeSQLExceptionTranslator(dBConnection.getDataSource()).translate("Running SQL", qq_SQL, qq_error);
}
finally {
dBConnection.cleanup(qq_cmd);
}
}
/**
* SQLDeleteHolding<p>
* <p>
* @param pHolding Type: Holding
*/
private void SQLDeleteHolding(Holding pHolding) {
DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
// -- =============== Original SQL ===============
// delete from Holding
// where CustomerName=:pHolding.CustomerName and
// StockName=:pHolding.StockName
// on session DBConnection
// -- ============================================
String qq_SQL = "delete from Holding " +
"where CustomerName=? and " +
"StockName=? ";
Object[] qq_SQLParams = new Object[] {
pHolding.getCustomerName(),
pHolding.getStockName()
};
dBConnection.getTemplate().update(qq_SQL, qq_SQLParams);
}
/**
* SQLInsertHolding<p>
* <p>
* @param pHolding Type: Holding
*/
private void SQLInsertHolding(Holding pHolding) {
DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
// -- =============== Original SQL ===============
// insert into Holding (CustomerName, StockName, Quantity, Price)
// values (:pHolding.CustomerName, :pHolding.StockName,
// :pHolding.Quantity, :pHolding.Price)
// on session DBConnection
// -- ============================================
String qq_SQL = "insert into Holding (CustomerName, StockName, Quantity, Price) " +
"values (?, ?, " +
"?, ?) ";
Object[] qq_SQLParams = new Object[] {
pHolding.getCustomerName(),
pHolding.getStockName(),
new Integer(pHolding.getQuantity()),
new Float(pHolding.getPrice())
};
dBConnection.getTemplate().update(qq_SQL, qq_SQLParams);
}
/**
* SQLSelectCustomer<p>
* <p>
* @param pName Type: TextData
* @return Customer
*/
private Customer SQLSelectCustomer(TextData pName) {
Customer aCustomer = new Customer();
int recsReturned = 0;
int qq_RowCount = 0;
DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
// -- =============== Original SQL ===============
// select * into :aCustomer from Customer
// where CustomerName = :pName
// on session DBConnection
// -- ============================================
String qq_SQL = "select * from Customer " +
"where CustomerName = ? ";
Object[] qq_SQLParams = new Object[] {pName };
// TODO [112,Info]: Using the * in a query rather than explicitly enumerating the column list is often inefficient.
JdbcTemplate qq_Template = dBConnection.getTemplate();
List qq_List = qq_Template.query(qq_SQL, qq_SQLParams, new BeanRowMapper(aCustomer, Customer.class));
if (!qq_List.isEmpty()) {
aCustomer = (Customer)DataAccessUtils.singleResult(qq_List);
}
qq_RowCount = qq_List.size();
recsReturned = qq_RowCount;
if (recsReturned == 1) {
return aCustomer;
}
else {
NoSuchCustomerException noSuchCust = new NoSuchCustomerException();
noSuchCust.setWithParams(Constants.SP_ER_ERROR, "Customer %1 does not exist", pName);
ErrorMgr.addError(noSuchCust);
throw noSuchCust;
}
}
/**
* SQLSelectHolding<p>
* <p>
* @param pSelHoldCustName Type: TextData
* @param pSelHoldStockName Type: String
* @return Holding
*/
private Holding SQLSelectHolding(TextData pSelHoldCustName, String pSelHoldStockName) {
Holding aHolding = new Holding();
int recsReturned = 0;
int qq_RowCount = 0;
DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
// -- =============== Original SQL ===============
// select * into :aHolding from Holding
// where CustomerName = :pSelHoldCustName
// and StockName = :pSelHoldStockName
// on session DBConnection
// -- ============================================
String qq_SQL = "select * from Holding " +
"where CustomerName = ? " +
"and StockName = ? ";
Object[] qq_SQLParams = new Object[] {
pSelHoldCustName,
pSelHoldStockName
};
// TODO [112,Info]: Using the * in a query rather than explicitly enumerating the column list is often inefficient.
JdbcTemplate qq_Template = dBConnection.getTemplate();
List qq_List = qq_Template.query(qq_SQL, qq_SQLParams, new BeanRowMapper(aHolding, Holding.class));
if (!qq_List.isEmpty()) {
aHolding = (Holding)DataAccessUtils.singleResult(qq_List);
}
qq_RowCount = qq_List.size();
recsReturned = qq_RowCount;
if (recsReturned == 1) {
return aHolding;
}
else {
NoSuchHoldingException noHolding = new NoSuchHoldingException();
noHolding.setWithParams(Constants.SP_ER_ERROR, "Customer %1 does not own this stock", pSelHoldCustName);
ErrorMgr.addError(noHolding);
throw noHolding;
}
}
/**
* SQLSelectHoldingList<p>
* <p>
* @param pName Type: TextData
* @return Array_Of_Holding<Holding>
*/
private Array_Of_Holding<Holding> SQLSelectHoldingList(TextData pName) {
Array_Of_Holding<Holding> aCustomersHoldingList = new Array_Of_Holding<Holding>();
DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
// -- =============== Original SQL ===============
// select * into :aCustomersHoldingList
// from Holding
// where CustomerName = :pName
// on session DBConnection
// -- ============================================
String qq_SQL = "select * " +
"from Holding " +
"where CustomerName = ? ";
Object[] qq_SQLParams = new Object[] {pName };
// TODO [112,Info]: Using the * in a query rather than explicitly enumerating the column list is often inefficient.
JdbcTemplate qq_Template = dBConnection.getTemplate();
aCustomersHoldingList = (Array_Of_Holding)qq_Template.query(qq_SQL, qq_SQLParams, new ArrayRowMapper(aCustomersHoldingList, Array_Of_Holding.class));
return aCustomersHoldingList;
}
/**
* SQLUpdateCashBal<p>
* <p>
* @param pCustomerName Type: TextData
* @param pCashBalance Type: float
*/
public void SQLUpdateCashBal(TextData pCustomerName, float pCashBalance) {
DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
// -- =============== Original SQL ===============
// update Customer
// set CashBalance = :pCashBalance
// where CustomerName = :pCustomerName
// on session DBConnection
// -- ============================================
String qq_SQL = "update Customer " +
"set CashBalance = ? " +
"where CustomerName = ? ";
Object[] qq_SQLParams = new Object[] {
new Float(pCashBalance),
pCustomerName
};
dBConnection.getTemplate().update(qq_SQL, qq_SQLParams);
}
/**
* SQLUpdateHolding<p>
* <p>
* @param pHolding Type: Holding
*/
private void SQLUpdateHolding(Holding pHolding) {
DBConnectionManager dBConnection = DBConnectionManager.getInstance("DBConnection");
// -- =============== Original SQL ===============
// update Holding set Quantity = :pHolding.Quantity
// where CustomerName=:pHolding.CustomerName and
// StockName=:pHolding.StockName
// on session DBConnection
// -- ============================================
String qq_SQL = "update Holding set Quantity = ? " +
"where CustomerName=? and " +
"StockName=? ";
Object[] qq_SQLParams = new Object[] {
new Integer(pHolding.getQuantity()),
pHolding.getCustomerName(),
pHolding.getStockName()
};
dBConnection.getTemplate().update(qq_SQL, qq_SQLParams);
}
} // end class CustomerMgr
// c Pass 2 Conversion Time: 1766 milliseconds