Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-dev] Fix for bug 256277 - Endless loop on @PrePersist (query pre flush() causes nested flush())

Hi,
   The following patch has been reviewed and checked in for bug# 256277

       http://bugs.eclipse.org/256277
       https://bugs.eclipse.org/bugs/attachment.cgi?id=122486&action=diff
       http://fisheye2.atlassian.com/changelog/eclipselink/?cs=3202

   Code-Review:
      Reviewed by Gordon and Tom - thank you

   Description:
Currently flush() can be nested causing an infinite loop or DB errors on a double commit. We have introduced a boolean flag on RepeatableWriteUnitOfWork that is true while we are flushing and use this flag to stop any nested flushing from occurring.

For a reproduction, we have a managed source entity that has some uncommitted changes. There is an unmanaged target entity that has a @PrePersist callback method that contains a query on the source .
      We do a final flush() or commit().
The result is that the @PrePersist method causes it's own flush() within a flush() - we need to disallow this. Originally I placed the logic to break out of a nested flush at the EJBQueryImpl.executeReadQuery() level, however after a code review this was moved to a more generic location in RepeatableWriteUnitOfWork.writeChanges().


   Test Results: OK
      JPA LRG: (1 expected PostClone failure)
[junit] Tests run: 1065, Failures: 1, Errors: 0, Time elapsed: 806.286 sec
      Foundation LRG: (2 expected getContainerAttributeName XML failures)
[junit] Tests run: 5626, Failures: 0, Errors: 2, Time elapsed: 694.761 sec
  (reran under rev 3197)
      JPA LRG:
[junit] Tests run: 1065, Failures: 1, Errors: 0, Time elapsed: 592.973 sec
      Core LRG:
[junit] Tests run: 6646, Failures: 0, Errors: 0, Time elapsed: 882.218 sec

   SVN
      Merged into rev 3197
      Created rev 3202



Back to the top