db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Lianza" <tlia...@hotmail.com>
Subject "no changes to save" on database update
Date Sun, 07 Mar 2004 15:26:02 GMT
Hello,

I've been using Torque on a project for the last few months and have just 
run into an issue about saving an update to the database.  I do this 
successfully in many places, but am stuck on one.

I have a table with a 2-column primary key plus one other column which is a 
BigDecimal.  I'm looking up the object based on the primary keys, and trying 
to update the BigDecimal.  Here is a code snippet:

List custprodlist = 
TblcustomerproductPeer.doSelectVillageRecords(prodfreqcrit);
Iterator cpit = custprodlist.iterator();
while(cpit.hasNext()){
	try{
		Record custprod = (Record)cpit.next();
		BigDecimal qant = custprod.getValue(1).asBigDecimal();

		//get the product/pair this row deals with - this identifies the primary 
keys
		Criteria thecustcrit = new Criteria();
		thecustcrit.add(TblcustomerproductPeer.CUSTOMERNUMBER, 
custprod.getValue(TblcustomerproductPeer.CUSTOMERNUMBER).asString());
		thecustcrit.add(TblcustomerproductPeer.ITEMNUMBER, 
custprod.getValue(TblcustomerproductPeer.ITEMNUMBER).asString());
		Tblcustomerproduct tempcp = 
(Tblcustomerproduct)TblcustomerproductPeer.doSelect(thecustcrit).get(0);

		//change the quantity
		tempcp.setQuantperday(qant);
		//TODO: figure out why this doesn't save
		tempcp.save();
	}catch(Exception loopex){
		logger.warn("Could not update the product frequency: "+loopex);
	continue;
}

So, CUSTOMERNUMBER and ITEMNUMBER are the primary keys.  It looks them up 
fine, I get a handle on that row, change the quantity (which is null in the 
database, via the debugger I can see that what I'm setting it to is 
non-null) and hit "save".  I get the error "no changes to save" and nothing 
changes in the database.  Any ideas?

Many thanks,
Tom

---
http://lianza.org/

_________________________________________________________________
Get a FREE online computer virus scan from McAfee when you click here. 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message