[ 
https://issues.apache.org/jira/browse/CAY-2735?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrus Adamchik updated CAY-2735:
---------------------------------
    Description: 
I have a Persistent object X with the following {{@PostPersist}} 

{noformat}
@PostPersist
public void postPersist() {
    setPropX(...calculation_based_on_id_);
    getObjectContext().commitChanges();
}
{noformat}

... and a CommitLogListener in "excludeFromTransaction" mode, that needs to see 
both the new object creation and "propX" change in the same "onPostCommit" call:

{noformat}
CommitLogModule.extend()
    .addListener(listener)
    .excludeFromTransaction()
    .module());
{noformat}

When I create and commit a new X,  it results in two commits in a single 
transaction (one from the user code, and another one - from PostPersist), with 
one INSERT event and one - UPDATE respectively. But my "listener" only receives 
the update and 2 ObjectId change events (the latter are not expected; they are 
not seen on a regular  commit)... 

Removing "excludeFromTransaction", results in the listener correctly receiving 
first an INSERT and then an UPDATE events. But since those come as separate 
calls, it is hard to match them together and make sense of the overall change. 

While I can probably find a workaround for my case, we need to think how the 
CommitLogFilter should behave when multiple operations occur in a single 
transaction.

  was:
I have a Persistent object X with the following {{@PostPersist}} 

{noformat}
@PostPersist
public void postPersist() {
    setPropX(...calculation_based_on_id_);
    getObjectContext().commitChanges();
}
{noformat}

And a CommitLogListener in "excludeFromTransaction" mode, used to set the value 
of "propX" in the same transaction as the main object creation:

{noformat}
CommitLogModule.extend()
    .addListener(listener)
    .excludeFromTransaction()
    .module());
{noformat}

When I create and commit a new X,  it results in two commits in a single 
transaction (one from the user code, and another one - from PostPersist), with 
one INSERT event and one - UPDATE respectively. But my "listener" only receives 
the update and 2 ObjectId change events (the latter are not expected; they are 
not seen on a regular  commit)... 

Removing "excludeFromTransaction", results in the listener correctly receiving 
first an INSERT and then an UPDATE events. But since those come as separate 
calls, it is hard to match them together and make sense of the overall change. 

While I can probably find a workaround for my case, we need to think how the 
CommitLogFilter should behave when multiple operations occur in a single 
transaction.


> Missing events in CommitLogListener in "excludeFromTransaction" mode
> --------------------------------------------------------------------
>
>                 Key: CAY-2735
>                 URL: https://issues.apache.org/jira/browse/CAY-2735
>             Project: Cayenne
>          Issue Type: Bug
>    Affects Versions: 4.2.B1
>            Reporter: Andrus Adamchik
>            Priority: Minor
>
> I have a Persistent object X with the following {{@PostPersist}} 
> {noformat}
> @PostPersist
> public void postPersist() {
>     setPropX(...calculation_based_on_id_);
>     getObjectContext().commitChanges();
> }
> {noformat}
> ... and a CommitLogListener in "excludeFromTransaction" mode, that needs to 
> see both the new object creation and "propX" change in the same 
> "onPostCommit" call:
> {noformat}
> CommitLogModule.extend()
>     .addListener(listener)
>     .excludeFromTransaction()
>     .module());
> {noformat}
> When I create and commit a new X,  it results in two commits in a single 
> transaction (one from the user code, and another one - from PostPersist), 
> with one INSERT event and one - UPDATE respectively. But my "listener" only 
> receives the update and 2 ObjectId change events (the latter are not 
> expected; they are not seen on a regular  commit)... 
> Removing "excludeFromTransaction", results in the listener correctly 
> receiving first an INSERT and then an UPDATE events. But since those come as 
> separate calls, it is hard to match them together and make sense of the 
> overall change. 
> While I can probably find a workaround for my case, we need to think how the 
> CommitLogFilter should behave when multiple operations occur in a single 
> transaction.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to