When executing the following code snippit:
Code:
// [...] (creating session s, beginning transaction)
IReducableTreeNode node = (IReducableTreeNode) s.load( IReducableTreeNode.class, new Long(138802));
// I get the warning on the next line
Iterator<? extends IReducableTreeNode> iter = node.getDescendants().iterator();
while (iter.hasNext()) {
IReducableTreeNode tn = iter.next();
System.out.println( tn);
}
I get the following warning:
Code:
23:35:29,967 [main] WARN at org.hibernate.engine.StatefulPersistenceContext.narrowProxy(StatefulPersistenceContext.java:614)
Narrowing proxy to class net.eigenvalue.callstylist.callreducerenv.calltree.CallNode - this operation breaks ==
This is strange, because I do not use any casts etc. Even though, it's just a regular interface method call, I tried to narrow the instance by the visitor pattern before -- that did not work either, the same warning is emitted.
As suggested by a different post, I can solve the problem in this special case by using get instead of load. Unfortunately, this is not possible in other contexts.
The relevant excerpt of the IReducableTreeNode interface:
Code:
public Collection<? extends IReducableTreeNode> getDescendants();
The concrete type of the the retrieved object is "CallNode" which implements the Collection getter/setter in a simple POJO manner.
The relevant excerpt of the mapping documents:
Code:
<class
name="IReducableTreeNode"
abstract="true">
<id name="pid">
<generator class="sequence"/>
</id>
<joined-subclass
name="net.eigenvalue.callstylist.callreducerenv.calltree.CallNode">
<key column="pid" />
<many-to-one name="parent"
class="net.eigenvalue.callstylist.callreducerenv.calltree.CallNode"
index="CallNodeParentIndex" />
<list name="descendants" inverse="true"
cascade="all-delete-orphan">
<key column="parent" />
<list-index column="index" />
<one-to-many
class="net.eigenvalue.callstylist.callreducerenv.calltree.CallNode" />
</list>
</joined-subclass>
</class>
The full stack trace to the warning message:
Code:
StatefulPersistenceContext.narrowProxy(Object, EntityPersister, EntityKey, Object) line: 614
DefaultLoadEventListener.returnNarrowedProxy(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType, PersistenceContext, Object) line: 204
DefaultLoadEventListener.proxyOrLoad(LoadEvent, EntityPersister, EntityKey, LoadEventListener$LoadType) line: 169
DefaultLoadEventListener.onLoad(LoadEvent, LoadEventListener$LoadType) line: 87
SessionImpl.fireLoad(LoadEvent, LoadEventListener$LoadType) line: 774
SessionImpl.internalLoad(String, Serializable, boolean, boolean) line: 746
ManyToOneType(EntityType).resolveIdentifier(Serializable, SessionImplementor) line: 266
ManyToOneType(EntityType).resolve(Object, SessionImplementor, Object) line: 303
TwoPhaseLoad.initializeEntity(Object, boolean, SessionImplementor, PreLoadEvent, PostLoadEvent) line: 113
OneToManyLoader(Loader).initializeEntitiesAndCollections(List, Object, SessionImplementor, boolean) line: 842
OneToManyLoader(Loader).doQuery(SessionImplementor, QueryParameters, boolean) line: 717
OneToManyLoader(Loader).doQueryAndInitializeNonLazyCollections(SessionImplementor, QueryParameters, boolean) line: 223
OneToManyLoader(Loader).loadCollection(SessionImplementor, Serializable, Type) line: 1916
OneToManyLoader(CollectionLoader).initialize(Serializable, SessionImplementor) line: 36
OneToManyPersister(AbstractCollectionPersister).initialize(Serializable, SessionImplementor) line: 520
DefaultInitializeCollectionEventListener.onInitializeCollection(InitializeCollectionEvent) line: 60
SessionImpl.initializeCollection(PersistentCollection, boolean) line: 1555
PersistentList(AbstractPersistentCollection).initialize(boolean) line: 341
PersistentList(AbstractPersistentCollection).read() line: 85
PersistentList.iterator() line: 115
NarrowTest.main(String[]) line: 16
(line 16 is the one with Iterator<? extends...)
I am using
Hibernate version: 3.1beta2
Thank you very much for your time and help.