Johannes,

sorry for the late reply, but here we go .. :-(. Does your Salutation object implement TimeStampable ? 'cause if not, Castor will not 'know' about this Salutation instance, as it has been discarded as a result of the previous transaction's commit.

Can you please post the (relevant parts of the) mapping for Customer and Salutation classes.

Regards
Werner

--Original Message Text---
From: [EMAIL PROTECTED]
Date: Mon, 12 Jul 2004 11:24:22 +0200


Hi all,

I have still a problem with long transactions or independent one-to-many relations.
I found some mails about that issue, but I could not find a solution.

So again the question:
How can I change independent relations in long transaction?

My Problem:
I have a independent one to many relation. That means, a object contains the relation to an object which should not be update or created when I try to update the "master" object. Like customer and salution. The salution should not be updated when I change the customers salution.
I use a "very" long transaction.

db.begin();
//geting an existing Customer from Database with wrong firstname "Johannnnnnes" and the existing salution object "unknown"
Customer customer = db.load("Customer.class", new Integer(22));
db.commit();
..
db.begin();
// fetching the "Mr." salution object
Salution newSalution = db.load("Salution.class", new Integer(1));
db.commit();
...
customer.setFirstname("Johannes");
customer.setSalution(newSalution);
..
db.begin();
db.update(customer);
db.commit();
..

I got the exception:
PersistStoreException: org.exolab.castor.jdo.TransactionAbortedException: Nested error: org.exolab.castor.jdo.PersistenceException: Object, [EMAIL PROTECTED], links to another object, [EMAIL PROTECTED] that is not loaded/updated/created in this transaction

If I create a new customer, set a salution object, the customer object will be stored and no one will try to insert or update a new salution. It works proper.

I tried setAutoStore(true).
I tried read-only in the mapping for sql and field.

Sure I could use short transaction, but this is my natural strategy. Is there a solution or some new ideas for my problem?

Thanks for helping me.

Johannes Ditters

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to