• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate - org.hibernate.AssertionFailure: no queued adds

 
Abhishek Gayakwad
Greenhorn
Posts: 4
Hibernate IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 is transient?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic