fix: calling scheduleForInsert twice#11835
Conversation
If scheduleForInsert was called in prePersist hook already, then persistNew need to check this case first, otherwise a ORMInvalidArgumentException will be thrown
|
I originally started at branch 3.3.x, but the bug exists also in 2.x. I just saw now, that the tests not working at 2.x. Before I fix the test I will wait for some review to fix all at once. |
|
Tests are already fixed, maybe someone has time to review. |
|
There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
|
PR still need review |
|
@greg0ire May you have a look at this PR please. |
From here I suppose: Lines 1392 to 1394 in 0f32569 |
|
Thanks @gseidel ! |
|
@greg0ire I dont understand why we need this, the fix here is to configure the relationship to cascade persist or not? The listener in the test re-implements cascade persist it seems to me. |
If
scheduleForInsertwas called inprePersisthook already, thenpersistNewneed to check this case first, otherwise aORMInvalidArgumentExceptionwill be thrown.Describing my use case:
Trying to implement some "two column polymorphism", see discusson #9928.
So I want to call a persist on an unmapped property. This works fine for most cases. But if the entity inside the unmapped property has some cascade persist to the entity carrying the unmapped property, then the
scheduleForInsertwill be called twice. Once for the cascading inside the hook and later on thepersistNewwhich called the hook at first. You may see the use case on the provided functional test.