Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] General Commit Operations
[CDO] General Commit Operations [message #501858] Fri, 04 December 2009 06:10 Go to next message
Michael Szediwy is currently offline Michael SzediwyFriend
Messages: 23
Registered: July 2009
Junior Member
Hi,

I want to execute some general operations on several model objects when
a transaction gets commited. E.g. set a timestamp. I tried to do this
within a CDOTransactionHandler in the committingTransaction method. But
it doesn't work. Why doesn't it work? And what can I do?

Thanks in advance ...

Michael

PS: I'm using the CDO head version
Re: [CDO] General Commit Operations [message #502831 is a reply to message #501858] Wed, 09 December 2009 20:35 Go to previous messageGo to next message
Victor Roldan Betancort is currently offline Victor Roldan BetancortFriend
Messages: 524
Registered: July 2009
Senior Member
Hi Michael,

according to the results of our test-cases, the CDOTransactionHandler
mechanism seems to be working fine. You can check by executing
org.eclipse.emf.cdo.tests.TransactionHandlerTest (you can fetch the
test-suite plugin from cvs):

org.eclipse.emf/org.eclipse.emf.cdo/test/org.eclipse.emf.cdo .tests

There you can see some example usages of the CDOTransactionHandler
mechanism. Are you sure your are registering the handler in the right
CDOTransaction instance?

Please note that
org.eclipse.emf.cdo.transaction.CDOTransactionHandler.commit tingTransaction(CDOTransaction,
CDOCommitContext) will only be called when CDOTransaction.commit() is
called for the instance in which it is registered. If you are calling
CDOTransaction.commit() from another instance, your handler won't be
notified: CDOTransactionHandler does not manage remote transaction
operations, only those local to certain instance in which it is
registered. If this is your case, you should take a look at CDOViewEvent
hierarchy:

org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent
org.eclipse.emf.cdo.view.CDOViewInvalidationEvent
org.eclipse.emf.cdo.view.CDOViewEvent
org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent
org.eclipse.emf.cdo.transaction.CDOTransactionStartedEvent

which you can listen to by registering IListener instances to your
CDOSession, CDOView or CDOTransaction instances, as they all implement
org.eclipse.net4j.util.event.INotifier.

Please take a look at
org.eclipse.emf.cdo.tests.TransactionHandlerTest.testCommitt ing(). It
should do what you are trying to achieve:

CDOAccumulateTransactionHandler handler = new
CDOAccumulateTransactionHandler();

CDOSession session = openModel1Session();
CDOTransaction transaction = session.openTransaction();
transaction.addTransactionHandler(handler);

transaction.getOrCreateResource("/test1");
transaction.commit();
assertEquals(1, handler.getNumberOfCommit());

transaction.close();
session.close();


If it still doesn't work for you, let us know, we will try to dig deeper.

Cheers,
Víctor.

Michael Szediwy escribió:
> Hi,
>
> I want to execute some general operations on several model objects when
> a transaction gets commited. E.g. set a timestamp. I tried to do this
> within a CDOTransactionHandler in the committingTransaction method. But
> it doesn't work. Why doesn't it work? And what can I do?
>
> Thanks in advance ...
>
> Michael
>
> PS: I'm using the CDO head version
Re: [CDO] General Commit Operations [message #502912 is a reply to message #502831] Thu, 10 December 2009 09:59 Go to previous message
Michael Szediwy is currently offline Michael SzediwyFriend
Messages: 23
Registered: July 2009
Junior Member
Hi Víctor,

thank you for the detailed explanation. In the end it was a mistake I
made. :-)

Thank you

Michi


Víctor Roldán Betancort wrote:
> Hi Michael,
>
> according to the results of our test-cases, the CDOTransactionHandler
> mechanism seems to be working fine. You can check by executing
> org.eclipse.emf.cdo.tests.TransactionHandlerTest (you can fetch the
> test-suite plugin from cvs):
>
> org.eclipse.emf/org.eclipse.emf.cdo/test/org.eclipse.emf.cdo .tests
>
> There you can see some example usages of the CDOTransactionHandler
> mechanism. Are you sure your are registering the handler in the right
> CDOTransaction instance?
>
> Please note that
> org.eclipse.emf.cdo.transaction.CDOTransactionHandler.commit tingTransaction(CDOTransaction,
> CDOCommitContext) will only be called when CDOTransaction.commit() is
> called for the instance in which it is registered. If you are calling
> CDOTransaction.commit() from another instance, your handler won't be
> notified: CDOTransactionHandler does not manage remote transaction
> operations, only those local to certain instance in which it is
> registered. If this is your case, you should take a look at CDOViewEvent
> hierarchy:
>
> org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent
> org.eclipse.emf.cdo.view.CDOViewInvalidationEvent
> org.eclipse.emf.cdo.view.CDOViewEvent
> org.eclipse.emf.cdo.transaction.CDOTransactionFinishedEvent
> org.eclipse.emf.cdo.transaction.CDOTransactionStartedEvent
>
> which you can listen to by registering IListener instances to your
> CDOSession, CDOView or CDOTransaction instances, as they all implement
> org.eclipse.net4j.util.event.INotifier.
>
> Please take a look at
> org.eclipse.emf.cdo.tests.TransactionHandlerTest.testCommitt ing(). It
> should do what you are trying to achieve:
>
> CDOAccumulateTransactionHandler handler = new
> CDOAccumulateTransactionHandler();
>
> CDOSession session = openModel1Session();
> CDOTransaction transaction = session.openTransaction();
> transaction.addTransactionHandler(handler);
>
> transaction.getOrCreateResource("/test1");
> transaction.commit();
> assertEquals(1, handler.getNumberOfCommit());
>
> transaction.close();
> session.close();
>
>
> If it still doesn't work for you, let us know, we will try to dig deeper.
>
> Cheers,
> Víctor.
>
> Michael Szediwy escribió:
>> Hi,
>>
>> I want to execute some general operations on several model objects
>> when a transaction gets commited. E.g. set a timestamp. I tried to do
>> this within a CDOTransactionHandler in the committingTransaction
>> method. But it doesn't work. Why doesn't it work? And what can I do?
>>
>> Thanks in advance ...
>>
>> Michael
>>
>> PS: I'm using the CDO head version
Previous Topic:Teneo: constraint error using mssql
Next Topic:Legacy Model Handler
Goto Forum:
  


Current Time: Thu Apr 25 23:25:47 GMT 2024

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

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

Back to the top