-->
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.  [ 1 post ] 
Author Message
 Post subject: collection was not processed by flush()
PostPosted: Thu Aug 31, 2006 5:21 pm 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

3.1

Mapping documents:

Post -> Author
Code:
<many-to-one name="author" class="com.foo.model.Author" cascade="none" outer-join="auto" update="true" insert="true" column="post_author_id" />


Author -> Permission
Code:
<set name="permissions" lazy="true" cascade="delete" sort="unsorted">
   <key column="permission_author_id"></key>
   <one-to-many class="com.foo.model.Permission" />
</set>


Code between sessionFactory.openSession() and session.close():

Code:
public void update(Post post, Integer[] categoryIds) throws DAOException
{
   try
   {
      Session session = getSession();
      session.update(post);

      post.getCategories().clear();

      for (Integer categoryId : categoryIds)
      {
         Category category = (Category) session.get(Category.class, categoryId);
         if (category != null) post.getCategories().add(category);
      }
   }
   catch (HibernateException e)
   {
      logger.fatal(Messages.getString("errors.hibernate-update"), e);
      throw new DAOException("errors.hibernate-update", e);
   }
}


Full stack trace of any exception that occurs:

Code:
org.hibernate.AssertionFailure: collection [com.foo.model.Author.permissions] was not processed by flush()
   at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:205)
   at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:332)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)


Name and version of the database you are using:

Postgres 8.something for Windows

The generated SQL (show_sql=true):

Nothing noteworthy.

Debug level Hibernate log excerpt:

Nothing noteworthy.

I'm had a hunt around the forum and the net for a solution to this problem but haven't found any solutions that work for me. I recently switched to a session per HTTP request pattern and ever since have been unable to update posts. I get the AssertionFailure on a one-to-many relationship (Author to Permission) from a many-to-one relationship on the object I'm updating (Post to Author). This doesn't happen when I create a new post.

Is this a problem with my mapping or a bug in Hibernate?


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

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.