You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Mike Kienenberger <mk...@gmail.com> on 2007/10/10 22:06:12 UTC

Does DataContext.rollbackChanges() in 1.1.4 leave transient objects in toManyList relationships?

Should I expect that DataContext.rollbackChanges() in 1.1.4 leave
transient objects for new objects in toManyList relationships
containing that new object?

I'm pretty sure that the answer is yes.

Re: Does DataContext.rollbackChanges() in 1.1.4 leave transient objects in toManyList relationships?

Posted by Mike Kienenberger <mk...@gmail.com>.
It's likely that it's the same bug that was found in Cayenne 1.1.4.
There's no clean fix if that's the case.  The workaround I originally
posted was to force each object affected back to a fault so it'd be
refetched on the next access with a cleaned up relationship list.  Not
sure how practical that is on a global basis.

On 4/30/08, Alexis <al...@gmail.com> wrote:
>
>  Hi,
>
>  i have the same issue with Cayenne 2.0 :
>  Some objects are inserted and added in a commited object's to-many
>  relationship.
>  An exception occured, we rollback the changes but the new objects remain in
>  the to-many relationship
>  as transient objects !
>  Is this a feature or a bug ?
>  Is there a clean workaround ?
>
>  Thanks for your answers
>
>
>
>  Mike Kienenberger wrote:
>  >
>  > Yeah, I hit this behavior in a unit test, but I wasn't sure if it was
>  > a Cayenne problem or something wrong that I did.
>  >
>  > This appears to fix the issue, although it's not really convenient:
>  >
>  >         // Rollback changes may leave transient objects in toMany Lists.
>  >         if (PersistenceState.COMMITTED ==
>  > dataObject.getPersistenceState())
>  >         {
>  >             dataObject.setPersistenceState(PersistenceState.HOLLOW);
>  >         }
>  >         dataObject.resolveFault();
>  >
>  >
>  >
>  > I've been working on maintenance for a Cayenne 1.1 project for the
>  > last few months, and due to some local mods (custom local event
>  > bridge, custom propagation of invalidation events between snapshots,
>  > and other minor tweeks), trying to upgrade Cayenne isn't practical at
>  > this point.   I did finally upgrade it from 1.1R2 to 1.1.4, though :-)
>  >
>  > On 10/11/07, Andrus Adamchik <an...@objectstyle.org> wrote:
>  >> Good question... Without looking at 1.1 source code, I'd say yes. But
>  >> I'd say running a test would be the best way to determine that.
>  >> (1.1.4? when was that? :-))
>  >>
>  >> Andrus
>  >>
>  >>
>  >> On Oct 10, 2007, at 11:06 PM, Mike Kienenberger wrote:
>  >>
>  >> > Should I expect that DataContext.rollbackChanges() in 1.1.4 leave
>  >> > transient objects for new objects in toManyList relationships
>  >> > containing that new object?
>  >> >
>  >> > I'm pretty sure that the answer is yes.
>  >> >
>  >>
>  >>
>  >
>  >
>
>
> --
>  View this message in context: http://www.nabble.com/Does-DataContext.rollbackChanges%28%29-in-1.1.4-leave-transient-objects-in-toManyList-relationships--tp13143656p16980077.html
>  Sent from the Cayenne - User mailing list archive at Nabble.com.
>
>

Re: Does DataContext.rollbackChanges() in 1.1.4 leave transient objects in toManyList relationships?

Posted by Alexis <al...@gmail.com>.
Hi,

i have the same issue with Cayenne 2.0 :
Some objects are inserted and added in a commited object's to-many
relationship.
An exception occured, we rollback the changes but the new objects remain in
the to-many relationship
as transient objects !
Is this a feature or a bug ?
Is there a clean workaround ?

Thanks for your answers


Mike Kienenberger wrote:
> 
> Yeah, I hit this behavior in a unit test, but I wasn't sure if it was
> a Cayenne problem or something wrong that I did.
> 
> This appears to fix the issue, although it's not really convenient:
> 
>         // Rollback changes may leave transient objects in toMany Lists.
>         if (PersistenceState.COMMITTED ==
> dataObject.getPersistenceState())
>         {
>             dataObject.setPersistenceState(PersistenceState.HOLLOW);
>         }
>         dataObject.resolveFault();
> 
> 
> 
> I've been working on maintenance for a Cayenne 1.1 project for the
> last few months, and due to some local mods (custom local event
> bridge, custom propagation of invalidation events between snapshots,
> and other minor tweeks), trying to upgrade Cayenne isn't practical at
> this point.   I did finally upgrade it from 1.1R2 to 1.1.4, though :-)
> 
> On 10/11/07, Andrus Adamchik <an...@objectstyle.org> wrote:
>> Good question... Without looking at 1.1 source code, I'd say yes. But
>> I'd say running a test would be the best way to determine that.
>> (1.1.4? when was that? :-))
>>
>> Andrus
>>
>>
>> On Oct 10, 2007, at 11:06 PM, Mike Kienenberger wrote:
>>
>> > Should I expect that DataContext.rollbackChanges() in 1.1.4 leave
>> > transient objects for new objects in toManyList relationships
>> > containing that new object?
>> >
>> > I'm pretty sure that the answer is yes.
>> >
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Does-DataContext.rollbackChanges%28%29-in-1.1.4-leave-transient-objects-in-toManyList-relationships--tp13143656p16980077.html
Sent from the Cayenne - User mailing list archive at Nabble.com.


Re: Does DataContext.rollbackChanges() in 1.1.4 leave transient objects in toManyList relationships?

Posted by Mike Kienenberger <mk...@gmail.com>.
Yeah, I hit this behavior in a unit test, but I wasn't sure if it was
a Cayenne problem or something wrong that I did.

This appears to fix the issue, although it's not really convenient:

        // Rollback changes may leave transient objects in toMany Lists.
        if (PersistenceState.COMMITTED == dataObject.getPersistenceState())
        {
            dataObject.setPersistenceState(PersistenceState.HOLLOW);
        }
        dataObject.resolveFault();



I've been working on maintenance for a Cayenne 1.1 project for the
last few months, and due to some local mods (custom local event
bridge, custom propagation of invalidation events between snapshots,
and other minor tweeks), trying to upgrade Cayenne isn't practical at
this point.   I did finally upgrade it from 1.1R2 to 1.1.4, though :-)

On 10/11/07, Andrus Adamchik <an...@objectstyle.org> wrote:
> Good question... Without looking at 1.1 source code, I'd say yes. But
> I'd say running a test would be the best way to determine that.
> (1.1.4? when was that? :-))
>
> Andrus
>
>
> On Oct 10, 2007, at 11:06 PM, Mike Kienenberger wrote:
>
> > Should I expect that DataContext.rollbackChanges() in 1.1.4 leave
> > transient objects for new objects in toManyList relationships
> > containing that new object?
> >
> > I'm pretty sure that the answer is yes.
> >
>
>

Re: Does DataContext.rollbackChanges() in 1.1.4 leave transient objects in toManyList relationships?

Posted by Andrus Adamchik <an...@objectstyle.org>.
Good question... Without looking at 1.1 source code, I'd say yes. But  
I'd say running a test would be the best way to determine that.  
(1.1.4? when was that? :-))

Andrus


On Oct 10, 2007, at 11:06 PM, Mike Kienenberger wrote:

> Should I expect that DataContext.rollbackChanges() in 1.1.4 leave
> transient objects for new objects in toManyList relationships
> containing that new object?
>
> I'm pretty sure that the answer is yes.
>