-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Developing a class hierarchy for a recursive table + SPs
PostPosted: Wed Feb 23, 2005 2:51 pm 
Regular
Regular

Joined: Thu Jul 01, 2004 12:13 am
Posts: 68
Location: San Diego, CA
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:


Top
 Profile  
 
 Post subject: mapping results of Stored Procedure to objects
PostPosted: Thu Dec 22, 2005 8:33 am 
Newbie

Joined: Thu Sep 08, 2005 2:34 am
Posts: 2
Hi,

I'm facing the same problem now.

I'm using Spring/Hibernate and executing a SP. The results from this SP does not map to a specific table in my d/b. I'm creating a custom object for the results from SP. Now the question is how do I get hibernate do the mapping for me ?

Did you find a solution ?

Thanks
Vaidya


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.