Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Finding detached objects(How to navigate back to detached objects after commit)
[CDO] Finding detached objects [message #905327] Thu, 30 August 2012 07:17 Go to next message
Anders  Jönsson is currently offline Anders JönssonFriend
Messages: 33
Registered: January 2012
Member
Hi,

I have CDO objects that are referenced from a "data structure". I want to update that structure in one batch AFTER a successful commit. The problem is to find the objects that where detached in the commit.

I have tried a few options:

CDOSessionInvalidationEvent:
Seems like the perfect fit since it gives you a CDOIDAndVersion object for every added, changed or detached object after a commit (from anywhere). Finding the actual added and changed objects is easy using view.getObject(cdoIDAndVersion.getID()). BUT how do I find the detached objects in/from the committing CDOTransaction? You can't use the same view.getObject method since detached objects are no longer present in the committing CDOTransaction.

CDOViewInvalidationEvent:
Another seemingly perfect fit. Gives you added, changed and detached object instances from the view receiving the event. BUT this event doesn't get sent to the committing transaction, only to all other views.

So, how do I use invalidation events, or some other mechanism, to get the actual instances of still referenced but removed (from a CDO perspective) objects from the committing transaction?

Regards
///Anders
Re: [CDO] Finding detached objects [message #905331 is a reply to message #905327] Thu, 30 August 2012 07:22 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 339
Registered: July 2009
Senior Member
Hi Anders,

You can attach a CDOTransactionHandler1 to your CDOTransaction to be
notified of attached/detached/modifyed objects.

Regards.

On 30/08/2012 09:17, Anders Jönsson wrote:
> Hi,
>
> I have CDO objects that are referenced from a "data structure". I want
> to update that structure in one batch AFTER a successful commit. The
> problem is to find the objects that where detached in the commit.
>
> I have tried a few options:
>
> CDOSessionInvalidationEvent:
> Seems like the perfect fit since it gives you a CDOIDAndVersion object
> for every added, changed or detached object after a commit (from
> anywhere). Finding the actual added and changed objects is easy using
> view.getObject(cdoIDAndVersion.getID()). BUT how do I find the detached
> objects in/from the committing CDOTransaction? You can't use the same
> view.getObject method since detached objects are no longer present in
> the committing CDOTransaction.
>
> CDOViewInvalidationEvent:
> Another seemingly perfect fit. Gives you added, changed and detached
> object instances from the view receiving the event. BUT this event
> doesn't get sent to the committing transaction, only to all other views.
>
> So, how do I use invalidation events, or some other mechanism, to get
> the actual instances of still referenced but removed (from a CDO
> perspective) objects from the committing transaction?
>
> Regards
> ///Anders
Re: [CDO] Finding detached objects [message #905336 is a reply to message #905331] Thu, 30 August 2012 07:35 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 5574
Registered: July 2009
Senior Member
Am 30.08.2012 09:22, schrieb Esteban Dugueperoux:
> Hi Anders,
>
> You can attach a CDOTransactionHandler1 to your CDOTransaction to be notified of attached/detached/modifyed objects.
Yes. Or if you need the IDs of detached objects only *after* a commit you can:

CDOCommitInfo commitInfo = transaction.commit();
List<CDOIDAndVersion> detachedObjects = commitInfo.getDetachedObjects();

If you need access to the detached CDOObjects *before* the commit you can:

Map<CDOID, CDOObject> detachedObjects = transaction.getDetachedObjects();
transaction.commit();

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] Finding detached objects [message #905353 is a reply to message #905336] Thu, 30 August 2012 08:15 Go to previous messageGo to next message
Anders  Jönsson is currently offline Anders JönssonFriend
Messages: 33
Registered: January 2012
Member
Eike and Esteban,

Thanks for your replies.

I need detached objects *after* the commit. BUT if I use:

CDOCommitInfo commitInfo = transaction.commit();
List<CDOIDAndVersion> detachedObjects = commitInfo.getDetachedObjects();

I still only have CDOIDAndVersion of the detached objects. How do I go from there to the objects?

Do I need to collect them myself before committing using for instance transaction.getDetachedObjects()?

Regards
///Anders
Re: [CDO] Finding detached objects [message #905360 is a reply to message #905353] Thu, 30 August 2012 08:24 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 5574
Registered: July 2009
Senior Member
Am 30.08.2012 10:15, schrieb Anders Jönsson:
> Eike and Esteban,
>
> Thanks for your replies.
> I need detached objects *after* the commit. BUT if I use:
>
> CDOCommitInfo commitInfo = transaction.commit();
> List<CDOIDAndVersion> detachedObjects = commitInfo.getDetachedObjects();
>
> I still only have CDOIDAndVersion of the detached objects. How do I go from there to the objects?
>
> Do I need to collect them myself before committing using for instance transaction.getDetachedObjects()?
Yes ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Previous Topic:Global AdapterFactory vs one per each EditingDomain
Next Topic:Programatically select Item in Editor in different window
Goto Forum:
  


Current Time: Mon Nov 24 07:04:06 GMT 2014

Powered by FUDForum. Page generated in 0.03366 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software