I noticed that in Hibernate Envers, all related collections of an entity are loaded lazily, regardless of what fetch type is set. So when auditquerying for entity that has a collection of other entities (both audited, of course), the collection is a SetProxy at first (I can see that when debugging).
So, how do I initialize that proxy? Using Hibernate.initialize has no effect (I suppose because ihbernate and Envers are using different proxy objects). I know I can initialize the set by iterating over its items, but that isn't an option for me because I have multiple collections in an entity and not to mention what that would do to the readability of the code.
I need to initialize them eagerly because I'm accessing the collection at a later point in time when the hibernate session is already closed (converting the domain objects into dtos).
I'm using Hibernate 3.5.6.
An enhancement is open for this issue.
I worked around this issue by explicitly calling size() method on all the associated collections.