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?