Hello I am strugglinh with my Folder object. A folder has a list of child and may have ONE father. So a one to many to itself and a one-to-one to itself.
I cannot make my one-to-one work probably. The one to one relation is done in my database by a field called FK_Father_Folder_ID. Right now the father of an Folder object is the object itself.
thanks
Hibernate version:2.1
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="data">
<class name="Folder" table="folder">
<id name="folderID" column="Folder_ID" type="java.lang.Integer" unsaved-value="0" >
<generator class="native"/>
</id>
<property name="folderName" column="Folder_Name" type="java.lang.String" not-null="true" />
<property name="folderCreatedDate" column="Folder_Created_Date" type="java.lang.Long" not-null="true" />
<one-to-one name="fatherFolder" class="Folder" cascade="all" />
<one-to-one name="project" class="Project" cascade="all" />
<list name="childfolders" table="folder" cascade="all">
<key column="FK_Father_Folder_ID"/>
<index column="list_idx" />
<one-to-many class="data.Folder"/>
</list>
<list name="pictures" table="picture" cascade="all">
<key column="FK_Folder_ID"/>
<index column="list_idx" />
<one-to-many class="data.Picture"/>
</list>
</class>
</hibernate-mapping>