Session.flush() Causes AssertionFailure

Description

After calling Session.save() with an entity, calling Session.flush() causes the following error.

org.hibernate.AssertionFailure: collection [com.example.myList] was not processed by flush()
at org.hibernate.engine.CollectionEntry.postFlush(CollectionEntry.java:205)
at org.hibernate.event.def.AbstractFlushingEventListener.postFlush(AbstractFlushingEventListener.java:333)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:28)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)

The mapping used was:

<component name="component" class="Component">
<property name="sequence" column="SEQUENCE" not-null="false" generated="insert"/>
<list name="myList" table="MY_LIST">
<key column="MY_LIST_KEY"/>
<index column="INDEX_COL"/>
<composite-element class="MyCompositeElement">
<property name="element" column="ELEMENT"/>
</composite-element>
</list>
</component>

Environment

None

Activity

Show:
S
August 20, 2009, 9:38 PM

It seems related to the fact that Hibernate is issuing a select to retrieve the generated properties of the component before persisting the list. EntityMetamodel.hasInsertGeneratedValues() returns true in 3.2.4, but in 3.1.3 it returns false and because of that 3.1.3 does not perform the select and you must explicitly call refresh().
Maybe it could cascade first and then get the generated values after?

S
August 20, 2009, 9:44 PM

If I set foundInsertGeneratedValue to false (with a debugger) in the EntityMetamodel's constructor before hasInsertGeneratedValues is set then the error no longer happens.

S
January 12, 2010, 12:19 PM

Test case to reproduce issue.

Brett Meyer
April 7, 2014, 5:43 PM

In an effort to clean up, in bulk, tickets that are most likely out of date, we're transitioning all ORM 3 tickets to an "Awaiting Test Case" state. Please see http://in.relation.to/Bloggers/HibernateORMJIRAPoliciesAndCleanUpTactics for more information.

If this is still a legitimate bug in ORM 4, please provide either a test case that reproduces it or enough detail (entities, mappings, snippets, etc.) to show that it still fails on 4. If nothing is received within 3 months or so, we'll be automatically closing them.

Thank you!

Brett Meyer
July 8, 2014, 3:11 PM

Bulk rejecting stale issues. If this is still a legitimate issue on ORM 4, feel free to comment and attach a test case. I'll address responses case-by-case. Thanks!

Assignee

Unassigned

Reporter

BrianD

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure