I am wondering the possibility of using the "Table-per-class-hierarchy" idiom would make sense for a recursive table. In the table the base type is "work folder" and either speciality folders or documents can be contained recursively through the use of a parent id key which points back to itself. I basically want to create an object structure that represents that folder/doc structure rather than one monolithic object.
If this is possible, could I then use Hibernate3's stored procedure mechanism to popopulate those tables as such (SPs are already written for this table)? I'm not totally sure how I can map back the stored procedure results to the objects. Moreover, a column in one type might mean something different in another type of folder/document.
Interesting problem. What are your experiences?
Thanks,
Lou
Hibernate version:
3.04 BETA
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="com.mitchell.services.technical.folderrepository.bo">
<class name="EpfDoc" table="EPF_DOC">
<id
column="DOC_ID"
name="id"
type="integer"
>
<generator class="identity" />
</id>
<property
column="CREATED_DT"
length="7"
name="createdDt"
not-null="true"
type="date"
/>
<property
column="CREATED_BY"
length="30"
name="createdBy"
not-null="true"
type="string"
/>
<property
column="NUM_KEY1"
length="22"
name="numKey1"
not-null="false"
type="integer"
/>
<property
column="ALPHA_KEY3"
length="80"
name="alphaKey3"
not-null="false"
type="string"
/>
<property
column="ALPHA_KEY4"
length="80"
name="alphaKey4"
not-null="false"
type="string"
/>
<many-to-one
class="EpfDoc"
name="docParent"
not-null="true"
>
<column name="DOC_PARENT_ID" />
</many-to-one>
<set
inverse="true"
lazy="true"
name="set"
>
<key column="DOC_PARENT_ID" />
<one-to-many class="EpfDoc" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: