Re: Exception Thrown when two people are editing the same record
Re: Exception Thrown when two people are editing the same record
- Subject: Re: Exception Thrown when two people are editing the same record
- From: Chuck Hill <email@hidden>
- Date: Tue, 12 Jul 2005 10:45:12 -0700
Hi Robert,
The behavior you describe depends on whether the two editors are
using the same EOF stack or different EOF stacks (e.g. across
instances or if multiple stacks are getting created in one
instance). The EO synchronization of EOF only works within on
instance. You can use the change notification framework from Project
Wonder to implement cross stack synchronization if you really need.
AFAIK this only reduces the incidence of conflicts, it does not
eliminate them.
You will need to handle exceptions like this in code. You can
identify the exception as an optimistic locking failure and determine
the object that caused the failure with these methods:
/**
* @param adaptorException exception from failue in saveChanges()
* @return <code>true</code> if the EOGeneralAdaptorException
represents an optimistic locking failure
*/
protected boolean isOptimisticLockingFailure
(com.webobjects.eoaccess.EOGeneralAdaptorException adaptorException)
{
NSDictionary failureInfo = adaptorException.userInfo();
String failure = (String) failureInfo.objectForKey
(EOAdaptorChannel.AdaptorFailureKey);
return (failure != null) && failure.equals
(EOAdaptorChannel.AdaptorOptimisticLockingFailure);
}
/**
* @param adaptorException exception from failue in saveChanges()
* @return EOEnterpriseObject that cause the call to saveChanges
() to fail
*/
protected EOEnterpriseObject objectSaveFailedOn
(com.webobjects.eoaccess.EOGeneralAdaptorException adaptorException)
{
EODatabaseOperation failedDBOperation = (EODatabaseOperation)
adaptorException.userInfo().objectForKey
(EODatabaseContext.FailedDatabaseOperationKey);
return (EOEnterpriseObject)failedDBOperation.object();
}
Then it is a matter of refreshing the object (merge the changes) or
invalidating the object (discard local changes), showing it to the
user and having them try to save again.
Chuck
On Jul 12, 2005, at 10:32 AM, Robert Snyder wrote:
Hello,
We are running into an exception when two people are editing a record
and the second person saves the record. As I understood EOF and the
optimistic locking, if two people are editing a record and person A
saves the record, and then person B saves the record, both get saved,
but person B's edits override person A's changes. That does happen;
however, some times we get the following exception thrown.
Any help on why this exception is thrown would be appreciated.
## 2005-07-11 19:27:14 Etc/GMT ##
DMSWOApplication.handleException
##
com.webobjects.eoaccess.EOGeneralAdaptorException:
updateValuesInRowDescribedByQualifier --
com.webobjects.jdbcadaptor.JDBCChannel method failed to update row in
database
at
com.webobjects.eoaccess.EODatabaseContext._exceptionWithDatabaseContex
tI
nformationAdded(EODatabaseContext.java:4676)
at
com.webobjects.eoaccess.EODatabaseContext.performChanges
(EODatabaseConte
xt.java:6384)
at
com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditing
Co
ntext(EOObjectStoreCoordinator.java:415)
at
com.webobjects.eocontrol.EOEditingContext.saveChanges
(EOEditingContext.j
ava:3165)
at CourseMaintenance.saveAction(CourseMaintenance.java:665)
at sun.reflect.GeneratedMethodAccessor643.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
KeyValueCodingProtectedAccessor.methodValue
(KeyValueCodingProtectedAcces
sor.java:54)
at
com.webobjects.foundation.NSKeyValueCoding
$_MethodBinding.valueInObject(
NSKeyValueCoding.java:1160)
at
com.webobjects.foundation.NSKeyValueCoding
$DefaultImplementation.valueFo
rKey(NSKeyValueCoding.java:1268)
at
com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java:
1539)
at
com.webobjects.foundation.NSKeyValueCoding$Utility.valueForKey
(NSKeyValu
eCoding.java:498)
at
com.webobjects.foundation.NSKeyValueCodingAdditions
$DefaultImplementatio
n.valueForKeyPath(NSKeyValueCodingAdditions.java:212)
at
com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java:
1600)
at
com.webobjects.appserver._private.WOKeyValueAssociation.valueInCompone
nt
(WOKeyValueAssociation.java:46)
at
com.webobjects.appserver._private.WOSubmitButton.invokeAction
(WOSubmitBu
tton.java:59)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(
WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicG
roup.java:110)
at
com.webobjects.appserver._private.WOConditional.invokeAction
(WOCondition
al.java:55)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(
WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicG
roup.java:110)
at
com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(
WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicG
roup.java:110)
at
com.webobjects.appserver._private.WOComponentContent.invokeAction
(WOComp
onentContent.java:31)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(
WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicG
roup.java:110)
at
com.webobjects.appserver._private.WOComponentContent.invokeAction
(WOComp
onentContent.java:31)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(
WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicG
roup.java:110)
at
com.webobjects.appserver._private.WOConditional.invokeAction
(WOCondition
al.java:55)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(
WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicG
roup.java:110)
at
com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java:82)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(
WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicG
roup.java:110)
at
com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:
945)
at
com.webobjects.appserver._private.WOComponentReference.invokeAction
(WOCo
mponentReference.java:104)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(
WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicG
roup.java:110)
at
com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:
945)
at
com.webobjects.appserver._private.WOComponentReference.invokeAction
(WOCo
mponentReference.java:104)
at
com.webobjects.appserver._private.WODynamicGroup.invokeChildrenAction(
WO
DynamicGroup.java:101)
at
com.webobjects.appserver._private.WODynamicGroup.invokeAction
(WODynamicG
roup.java:110)
at
com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java:
945)
at com.webobjects.appserver.WOSession.invokeAction
(WOSession.java:1166)
at
com.webobjects.appserver.WOApplication.invokeAction
(WOApplication.java:
1375)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchW
it
hPreparedPage(WOComponentRequestHandler.java:196)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchW
it
hPreparedSession(WOComponentRequestHandler.java:287)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchW
it
hPreparedApplication(WOComponentRequestHandler.java:322)
at
com.webobjects.appserver._private.WOComponentRequestHandler._handleReq
ue
st(WOComponentRequestHandler.java:358)
at
com.webobjects.appserver._private.WOComponentRequestHandler.handleRequ
es
t(WOComponentRequestHandler.java:435)
at
com.webobjects.appserver.WOApplication.dispatchRequest
(WOApplication.jav
a:1306)
at
com.webobjects.appserver._private.WOWorkerThread.runOnce
(WOWorkerThread.
java:173)
at
com.webobjects.appserver._private.WOWorkerThread.run
(WOWorkerThread.java
:254)
at java.lang.Thread.run(Thread.java:552)
Robert
____________________________________________
Robert Snyder, Director
World Campus Data Management Services
The Pennsylvania State University
105 Mitchell Building
University Park PA 16802
Phone: 814-865-0912 Fax: 814-865-4406
E-mail: email@hidden
URL: http://www.worldcampus.psu.edu
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - a book for intermediate WebObjects developers
who want to increase their overall knowledge of WebObjects, or those
who are trying to solve specific application development problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
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