Hi,
I've been working on this for 2 days now, without getting anywhere on it. I will
greatly appreciate any help!
My problem is as follows:
I have a JTree which is used to show a hierarchy of Folders (just like a regular file system). Each folder which is represented through one of three node types (which all extends HierarchyNode). My problem is that while adding and deleting nodes from the JTree works just fine before i implemented Hibernate, things just doesn't play that well with Hibernate.
It seems like everything is fine. New child objects are perfectly added to the children list at its parent, TreePaths work fine - but somehow JTree just can't seem to figure out when i modify/add/delete objects from one of the Tree nodes.
As you may notice, i'm having trouble explaining the problem excactly, because i can't find one single thing to put my finger on. TreeModelEvents are issued correctly, all indexes look fine, all object references look good...but still the Tree will not update correctly.
Would anyone have experience using JTree and Hibernate together?
My HierarchyNode is mapped as follows:
Code:
<hibernate-mapping>
<class name="hierarchy.entities.HierarchyNode" table="hierarchynode" >
<id name="id" type="java.lang.Integer" column="id" >
<generator class="increment" />
</id>
<discriminator column="type" type="java.lang.String"/>
<property name="name" type="java.lang.String" column="name" length="200" />
<many-to-one name="parent" column="parent_id" class="hierarchy.entities.HierarchyNode" />
<!-- By setting cascade="none", we prevent the referenced agreement in the agreement table
from being deleted when an association in the track_agreement table is deleted -->
<bag name="children" inverse="true" lazy="false" cascade="all">
<key column="parent_id"/>
<one-to-many class="hierarchy.entities.HierarchyNode" />
</bag>
<subclass name="hierarchy.entities.HierarchyRootNode" discriminator-value="ROOT" />
<subclass name="hierarchy.entities.TrackHierarchyNode" discriminator-value="TRACK" />
<subclass name="hierarchy.entities.AlbumHierarchyNode" discriminator-value="ALBUM" />
</class>
</hibernate-mapping>
Any help will be greatly appreciated!