-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: org.hibernate.AssertionFailure: no queued adds
PostPosted: Thu Apr 15, 2010 7:34 am 
Newbie

Joined: Tue Dec 04, 2007 6:30 am
Posts: 1
org.hibernate.AssertionFailure: no queued adds
Getting above exception while flush

Use case – In our application, before doing any logical operation we persist whole state of statefull EJB including session to file or in memory byte [], and we restore this state if we encounter any exception. In this particular case I have performed following steps.
1. Fetch an object which has a list (size>0, lazy = true) in it.
2. Add another object in this list.
3. Serialize session.
4. Restore session.
5. Try to call flush on session, and we get the following exception.
Exception in thread "main" org.hibernate.AssertionFailure: no queued adds
at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:67)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:182)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions
(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush
(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
at Main.main(Main.java:46)


This problem comes because of usage of bag and transient variable (transient List operationQueue) in AbstractPersistentCollection class of hibernate. Bag doesn’t get initialized when object is added to it; instead this object gets added to operationQueue List which is transient so when we restore it back previous value is lost.

Solution
1. Eagerly load collection (lazy = false)
2. Use set instead of bag

Please suggest me any other solution for solving this problem. Why operationQueue object transient?


Top
 Profile  
 
 Post subject: Re: org.hibernate.AssertionFailure: no queued adds
PostPosted: Tue May 18, 2010 3:18 pm 
Newbie

Joined: Tue May 18, 2010 2:56 pm
Posts: 1
We have the same problem with Spring WebFlow and Hibernate. A PersistentBag is created by Hibernate and does not fully survive serial/deserialization by WebFlow. It loses some of its state and leads to the "no queued adds" exception.

We replaced the bag with a new implementation of a list (copying the bag's contents into the new list) and this seemed to workaround the issue.

A pure Webflow solution is to switch off snapshots - if it can be tolerated.

We're not quite sure why some of the Bag's attributes are marked with the transient modifier, but think it may be for performance reasons?


Top
 Profile  
 
 Post subject: Re: org.hibernate.AssertionFailure: no queued adds
PostPosted: Mon Jul 30, 2012 12:42 am 
Newbie

Joined: Mon May 12, 2008 4:07 pm
Posts: 5
We had the same issue with Hibernate and Spring Web Flow when adding a new child to a list in the parent entity.

There are two easier workarounds,
1) use a Hibernate User Type to override the default PersistentBag implementation of the list.
Apply @org.hibernate.annotations.Type(type="org.hibernate.collection.PersistentList") on top of @OneToMany

2) save/merge the parent object instead of the transient child.
parent.getChildren().add(0, transientChild);
entityManager.merge(parent); // cascade save

Note the funny syntax on the line, parent.getChildren().add(0, transientChild); this is to solve a defect in Hibernate reported here, https://hibernate.onjira.com/browse/HHH-5855.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.