Hi
Ok, there are 2 ways to do this. The hard way is to simulate a short
transaction for a long transaction. Instead of calling update, you:
- load the object (and any dependent objects)
- implement a copy function in your object, which copies attributes from one
object to the other
This way, you are performing everything (loading, updating) in one
transaction. Castor does not complain. Although this works, but it's kinda
stupid, since you are doing what the persistence layer is meant to do for
you. So, I have taken a closer look at castor's code.
I found that this piece of code (in ClassMolder.java) is causing 1:1
relationship to fail:
// yip: user're pretty easily to run into cache
// integrity problem here, if user forgot to create
// "value" explicitly. Let's put error message here
if ( value != null && !tx.isRecorded( value ) )
throw new PersistenceException(
"Object, "+object+", links to another object, "+value
+" that is not loaded/updated/created in this transaction");
>From the comments, it's meant to protect the cache from being corrupted if
you forget to create the dependent object explicitly.
I commented it out and it seems to perform long updates perfectly. However,
I don't know what side effects it will cause. This is where I need Castor
team's help (from the comments, I suspect this calls for Thomas).
I will carry on testing the code. Maybe I might find some other hints.
Keith C
-----Original Message-----
From: Toni Charlot [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 23 October 2001 1:40 p.m.
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Long Transaction
Hello Keith,
can you share that, por favor.
-----Original Message-----
From: Keith Chew [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 22, 2001 7:42 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Long Transaction
Ignore this mail. I know a way to fix my problem.
Regards
Keith C
-----Original Message-----
From: Keith Chew [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 23 October 2001 11:34 a.m.
To: [EMAIL PROTECTED]
Subject: [castor-dev] Long Transaction
Hi
Same scenarion Product and ProductGroup example. Creation and lookup is
working fine now (all I needed to do was to load ProductGroup in the same
transaction as the one used to create the Product).
Now I am testing long transaction support.
When I assign a new ProductGroup to the product and call update(), Castor
reports:
23.10,11:09:04,954 ERROR [CastorJDOImpl] -
org.exolab.castor.jdo.PersistenceException: Object, myapp.Product@74b0dc,
links to
another object, myapp.ProductGroup@771dc that is not loaded/updated/created
in this transaction.
>From the source, it writes:
// yip: user're pretty easily to run into cache
// integrity problem here, if user forgot to create
// "value" explicitly. Let's put error message here
if ( value != null && !tx.isRecorded( value ) )
throw new PersistenceException(
"Object, "+object+", links to another object,
"+value
+" that is not loaded/updated/created in this
transaction");
This is true because the original ProductGroup was created a while ago in
another transaction. It's kept in cache, so it's impossible to update that
attribute in a long transaction.
Is this the expected behavior?
Keith C
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev