We're updating the issue view to help you get more done. 

lazy properties, events and collection xxx was not processed by flush exception and EJB3 incompatibility

Description

It is realted to anomaly: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1540

'When using custom event listeners, sometimes you mess with (and initialize) lazy collections by mistake, which causes CollectionEntry.postFlush(PersistentCollection) to throw an AssertionFailure'

It is questionable why AT ALL exception is raised in this case!

What is the most important: EJB3 spec is not prohibiting to check/read/ object involved in the event, so current implementation is agains EJB3 spec.

Events are often used for validation so it is quite probable that the lazy property (collection) has to be accessed - and when it is lazy and not initialized before the exception is raised. Why hibernate cannot treat it in nicer way and allow such actions.
One workaround is to not-use-lazy (very bad).
Second workaround: in the code outside flush (not in event) pre-initialize all lazy properties (in fact simulation of 'not-lazy).

Environment

None

Status

Assignee

Unassigned

Reporter

Tomasz Bech

Components

Affects versions

3.2.0.cr2

Priority

Major