Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Hibernate - org.hibernate.AssertionFailure: no queued adds

 
Greenhorn
Posts: 4
IntelliJ IDE Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic