Event listener flush infinite loop

Description

Using an event listener (eg. PreDeleteEventListener) that calls flush itself, leads to infinite loop where flush re-triggers the same event.

Use case: batch processing inside event listener, where entity manager’s flush and clear is called after each batch was processed.

Environment

None

Activity

Show:
Steve Ebersole
December 2, 2020, 2:43 PM

Triggering flushes from a flush is not supported. In fact you need to be careful about even loading things into the Session during flush - it is also not technically supported

Alex CD
December 2, 2020, 3:30 PM

Shouldn’t this be handled better instead of an infinite loop?

Such as a mechanism that detects a flush is occurring and throw an error instead.

Steve Ebersole
December 2, 2020, 3:50 PM

To be honest, I have never seen this result in an infinite loop. And you did not attach a reproducer, so…

Usually the outcome is a CCME

Rejected

Assignee

Unassigned

Reporter

Alex CD

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure