Before doing this, I'd like to get some feedback about these warnings
cropping up, just in case there is a valid use case that we're missing.
On Fri, Oct 5, 2018 at 2:46 AM andrea boriero <andrea(a)hibernate.org> wrote:
I would say to log a warning when the entity is detached and then
the queued operations.
On Fri, 5 Oct 2018 at 07:25, Gail Badner <gbadner(a)redhat.com> wrote:
> Guillaume has reviewed my PR and I've pushed the fix to master.
> I still think the inconsistency should be resolved. I have no plans to do
> any more on this without any feedback.
> On Tue, Oct 2, 2018 at 6:16 PM Gail Badner <gbadner(a)redhat.com> wrote:
> > Since I haven't heard anything back, I've gone ahead and updated my PR
> > to ignore queued operations when merging a detached collection. This
> > the functionality that was in place prior to HHH-5855 (which caused
> > HHH-11209).
> > In addition I've added warnings for the following situations:
> > * a detached collection is being merged that has queued operations;
> > * a collection with queued operations is attached to a session;
> > * a collection with queued operations is detached from a session.
> > I've also added a test case that shows that Session#merge and
> > Session#saveOrUpdate have different results when called on an entity
> with a
> > collection with queued operations. When Session#merge is called, the
> > operations are ignored. When Session#saveOrUpdate is called, the queued
> > operations are executed on flush.
> > I don't like this inconsistency, but I'm not sure what to do about it.
> > don't think it's a good idea to have collections floating around with
> > queued operations. As far as the application knows, it is just an
> > uninitialized collection. I can see that the entity could find its way
> > a new session, with surprising results.
> > IIUC, an application probably shouldn't detach an entity with a
> > in this state (having queued operations), so I think it makes sense
> that a
> > warning be logged when this happens. On the other hand, the warning will
> > also be logged if a transaction involving updates to a collection with
> > queued operations fails.
> > I would really appreciate some feedback on this, since HHH-11209 is a
> > regression that really should be fixed.
> > Thanks,
> > Gail
> >  https://github.com/hibernate/hibernate-orm/pull/2460
> > On Fri, Sep 28, 2018 at 6:27 PM Gail Badner <gbadner(a)redhat.com> wrote:
> >> HHH-11209 involves a bug merging a detached entity with an
> >> collection that has queued operations.
> >> After looking into this issue I found a bug
> >> where AbstractPersistentCollection#operationQueue was not being cleared
> >> after a commit, if there was no cascade mapped for the collection.
> >> I've fixed that in a PR. 
> >> After that fix, the detached entity in the test case attached to
> >> HHH-11209 has an uninitialized entity without any queued operations
> >> commit, which can be merged successfully in a new session/transaction.
> >> There is still a problem when Hibernate tries to merge a detached
> >> has an uninitialized collection with queued operations though. My PR
> >> UnsupportedOperationException in this case, and there is a test case
> >> reproduces it.
> >> I've been working on a fix to add support for this, but I have my
> >> that it really should be supported. I see that prior to fixing HHH-5855
> >> (which caused HHH-11209), Hibernate simply ignored the queued
> operations in
> >> the detached collection. .
> >> The fix for HHH-5855 properly dealt with merging a managed collection
> >> that was uninitialized with queued operations. It introduced the bug
> >> a NullPointerException would get thrown if that collection was
> >> If we want to support merging the queued operations, then I would
> >> consider that an improvement. Would this be a worthwhile improvement?
> >> guessing not, but I wanted to get some opinions.
> >> For now, I see a couple of ways to deal with this so that HHH-11209 can
> >> be wrapped up:
> >> 1) ignore queued operations in a detached collection when merging, as
> >> done before HHH-5855 was fixed.
> >> 2) clear the queued operations when the collection is detached.
> >> Comments?
> >> Thanks,
> >> Gail
> >>  https://github.com/hibernate/hibernate-orm/pull/2460
> >> 
> hibernate-dev mailing list