the ObjectModifiedException highlights to you the fact that somebody else (for example within another thread of the same application) has modified the same object you are about to persist. For this to happen, you do not require long transactions to be part of your game. All that is required is two threads loading the same object instance (through its identity), update a property and try to commit the transaction. As part of the commit, a SQL statement will be executed that (indirectly) checks whether the underlying object has been modified - if so, a ObjectModifiedException is thrown.
I hope this answers your question. If not, please do not hesitate to follow up.
Regards
Werner
--Original Message Text---
From: Avalivin Jhons
Date: Mon, 5 Jul 2004 12:15:08 +0100 (BST)
Hi,
I am gating org.exolab.castor.jdo.ObjectModifiedException: Timestamp mismatched! exception while updating object.
The cache-type cache="none" in the mapping file.
I am not using long transaction.(dirty="ignore")
The AutoStore property of the db object is set to true. (db.setAutoStore(true) )
Note: The exception occurs only when I update a typical object. For all other type objects there is no such error.
Here is the part of the mapping file and part of the code.
<class name="MAGE.QuantitationType" extends="MAGE.Identifiable" identity="id" key-generator="SEQUENCE" >
<cache-type cache="none"/>
<map-to table="TT_QuantitationType"/>
<field name="id" type="big-decimal">
<sql name="ID" type="numeric"/>
</field>
<field direct="true" name="isBackground" type="string">
<sql name="isBackground" type="char" dirty="ignore"/>
</field>
<field direct="true" name="channel" type="big-decimal">
<sql name="channel_ID" type="numeric" dirty="ignore"/>
</field>
<field direct="true" name="dataType" type="MAGE.OntologyEntry">
<sql name="dataType_ID" dirty="ignore"/>
</field>
<field direct="true" name="scale" type="MAGE.OntologyEntry">
<sql name="scale_ID" dirty="ignore"/>
</field>
</class>
synchronized boolean rebuildObject(HttpServletRequest request)
{
try{
DBThread DB_Thread = new DBThread(new DBPool());
try{
DB_Thread.start();
System.out.println("Starting the Castor engine ..");
while(! DB_Thread.isFinish()){
System.out.println("wait...");
this.wait(10);
}
}
catch(Exception e){
e.printStackTrace();
return false;
}
Vector objectStack= (Vector)session.getAttribute("object_stack");
Description description=null;
String value=null;
for(int i=objectStack.size()-1; i>=0; i--)
{
Object object=objectStack.elementAt(i);
String className=((object.getClass().toString()).substring(object.getClass().toString().indexOf(".",0)+1,object.getClass().toString().length())).trim();
Field publicFields[] = object.getClass( ).getFields( );
for(int j=0;j<publicFields.length;j++)
{
Field f=publicFields[j];
if(f.getName().equals("roleName") || f.getName().equals("parentClassList") ) continue;
value= request.getParameter((i+1)+":"+className+":"+f.getName());
if(value!=null){
if(f.getType().toString().endsWith("String")) {
if(value.length()>4000) continue;
f.set(object,value);
}
if(f.getType().toString().endsWith("Integer")){
f.set(object, new Integer(Integer.parseInt(value)));
}
if(f.getType().toString().endsWith("Long")){
f.set(object, new Long(Long.parseLong(value)));
}
if(f.getType().toString().endsWith("Double")) {
f.set(object, new Double(Double.parseDouble(value)));
}
if(f.getType().toString().endsWith("Float")){
f.set(object, new Float(Float.parseFloat(value)));
}
}
}
if(object instanceof QuantitationType){
value= request.getParameter("QuantitationType:description");
if(!( value==null || value.equals(""))){
description=new Description();
description.setText(value);
DB_Thread.getDb().begin();
DB_Thread.getDb().create(description);
DB_Thread.getDb().commit();
((QuantitationType)object).addDescriptions(description);
}
}
DB_Thread.getDb().begin();
DB_Thread.getDb().update(object); // Fails here for QuantitationType Objects.
DB_Thread.getDb().commit();
this.wait(200);
}
DB_Thread.submitDb();
session.removeAttribute("object_stack");
}
catch(Exception e){
e.printStackTrace();
return false;
}
return true;
}
may I get some help regarding this please?
Regards,
Avalovin.
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now --0-1504164435-1089026108=:81777--
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
