Re: Error updating row in database
Re: Error updating row in database
- Subject: Re: Error updating row in database
- From: Alexander Spohr <email@hidden>
- Date: Wed, 13 Sep 2006 20:20:52 +0200
sorry david,
but doing 2 saveChanges in row kills the use of a transaction-based
database. if the second save fails you’re in the rain - as paul
already said, and you felt yourself.
better override accountNumber:
public String accountNumber()
{
if(super.accountNumber() == null)
return this.pkID();
return super.accountNumber();
}
that works even if you allow to change accountNumber.
and that’s what object-orientation is for, right? ;)
atze
Am 12.09.2006 um 14:00 schrieb David Griffith:
Hi all,
Using WO 5.3 with mySQL, I have an entity that has a primary key
(int) and when I save a record in the database, another attribute
(of type String) gets assigned the value of the primary key also.
To do this, I have to first save the record in the database in
order for the primary key to be generated. Then I assign the
primary key value to the other attribute and resave the record.
Something like this:
ec.saveChanges(); >-- saves the record to the database, assigns
the primary key
myEOObject.setAccountNumber(myEOObject.pkID().toString());
ec.saveChanges();
Obviously I am accessing the primary key via an accessor method of
my custom class using the EOUtilities framework.
Anyway, the problem is that occasionally (maybe 10% of the time)
the row fails to update and generates an exception stating 'failed
to update row in database'. Everything is saved fine, the primary
key is assigned, but after the second ec.saveChanges() is where it
fails.
Does anyone have any idea why that might be? Is it perhaps because
it is trying to update the database too quickly after a previous
update?
Kind regards,
David.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40freeport.de
This email sent to email@hidden
Freeport & Soliversum
Alexander Spohr
email@hidden
www.freeport.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden