I have a class with a collection marked as lazy. None of my code is interacting with the collection property, but I'm noticing that it is being loaded during a flush.
I stepped through some of the hibernate code (specifically the PojoEntityTuplizer and AbstractEntityTuplizer) and saw that it wasn't treated "channels" as lazy. I *think* it's because lazyAvailable is false (inside EntityMetamodel) due to the class level lazy attribute on "Playlist". I didn't think that had anything to do with whether or not a lazy collection is loaded though. I fear I'm going down the wrong path here, so thought I'd ask for help :)
thanks
sam
Stack trace from a dumpStack I added to getChannels
Code:
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1206)
at Playlist.getChannels(MediaCollection.java:116)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.getPropertyValue(AbstractEntityTuplizer.java:277)
at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyValue(AbstractEntityPersister.java:3586)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:131)
at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:122)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:65)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:811)
... snipped ...
The mapping:
Code:
<class name="Playlist" table="playlist" lazy="false" discriminator-value="0">
<cache usage="nonstrict-read-write"/>
<id name="id" column="id" type="long">
<generator class="MyIdentifierGenerator"/>
</id>
<discriminator column="discriminator" type="integer"/>
<version name="version" column="version" type="integer"/>
<set name="channels" lazy="true" inverse="true" cascade="all-delete-orphan">
<key column="playlist_id"/>
<one-to-many class="Channel"/>
</set>
<subclass name="VideoPlaylist" lazy="false" discriminator-value="1" >
</subclass>
<subclass name="AudiaPlaylist" lazy="false" discriminator-value="2">
</subclass>
</class>
Hibernate version: 3.2.6