-->
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: Tree Like Structure
PostPosted: Fri Jul 02, 2004 7:06 am 
Newbie

Joined: Fri Jul 02, 2004 6:47 am
Posts: 12
I have a Tree like structure where top node is attached to multiple sub-nodes through an association table(many-to-many relationship). This can go down upto 3-4 levels.
I want to load the complete tree in one go.
My problem is that even with 3-4 rows in one table, Hibernate issues 25-30 sqls. Utimately we will have few thousands of rows.
Can you please help in this as I am new to Hibernate.
I am using Hiberante V2.1.4 and DB is DB2 7.1

I am issuing a simple query like
Query q = hibSession.createQuery("select p from BasePid as p");

Thanks in advance

I am attaching my mappings doc

<hibernate-mapping package="com.myquest.model">

<class name="BasePid" table="BASE_PID" lazy="false" mutable="false">
<id name="nodeId" type="long" unsaved-value="0" >
<column name="PID_ID" sql-type="char(32)" />
<generator class="uuid.hex"/>
</id>


<property name="dispStyle">
<column name="PID_DSPL_STYL_CD"/>
</property>


<map name="lblMap" table="BASE_PID_I18N" outer-join="true">
<key column="PID_ID"/>
<index column="LCLE_CD" type="string"/>
<element column="LBL_TX" type="string"/>
</map>

<map name="childMap" table="BASE_PID_PID_SCTN" outer-join="true" order-by= "SCTN_SQ">
<key column="PID_ID"/>
<index column="SCTN_SQ" type="float"/>
<many-to-many class="BasePidSctn" column="PID_SCTN_ID" outer-join="true"/>
</map>

</class>


<class name="BasePidSctn" table="BASE_PID_SCTN" lazy="false" mutable="false">
<id name="nodeId" type="long" unsaved-value="0" >
<column name="PID_SCTN_ID" sql-type="char(32)" />
<generator class="uuid.hex"/>
</id>



<property name="dispStyle">
<column name="PID_DSPL_STYL_CD"/>
</property>


<map name="lblMap" table="BASE_PID_SCTN_I18N" outer-join="true">
<key column="PID_SCTN_ID"/>
<index column="LCLE_CD" type="string"/>
<element column="LBL_TX" type="string"/>
</map>
<map name="linksMap" table="BASE_PID_SCTN_LINK" outer-join="true">
<key column="PID_SCTN_ID"/>
<index column="LINK_SQ" type="float"/>
<element column="LINK_ID" type="long"/>
</map>
<map name="childMap" table="BASE_PID_SCTN_ELMN" outer-join="true"
order-by="CHLD_SQ" where = "CHLD_PID_SCTN_ID = 0 ">
<key column="PID_SCTN_ID"/>
<index column="CHLD_SQ" type="float"/>
<many-to-many class="BasePidElmn" column="PID_ELMN_ID" outer-join="true"/>
</map>

<map name="sctnMap" table="BASE_PID_SCTN_ELMN" outer-join="true"
order-by="CHLD_SQ" where = "CHLD_PID_SCTN_ID &lt;&gt; 0 ">
<key column="PID_SCTN_ID"/>
<index column="CHLD_SQ" type="float"/>
<many-to-many class="BasePidSctn" column="CHLD_PID_SCTN_ID" outer-join="true"/>
</map>

</class>


<class name="BasePidElmn" table="BASE_PID_ELMN" lazy="false" mutable="false">

<id name="nodeId" type="long" unsaved-value="0" >
<column name="PID_ELMN_ID" sql-type="char(32)" />
<generator class="uuid.hex"/>
</id>


<property name="dispStyle">
<column name="PID_DSPL_STYL_CD"/>
</property>


<property name="valSysName">
<column name="VL_SYST_NM"/>
</property>

<property name="valName">
<column name="VL_NM"/>
</property>


<map name="lblMap" table="BASE_PID_ELMN_I18N" outer-join="true">
<key column="PID_ELMN_ID"/>
<index column="LCLE_CD" type="string"/>
<element column="LBL_TX" type="string"/>
</map>
<map name="linksMap" table="BASE_PID_ELMN_LINK" outer-join="true">
<key column="PID_ELMN_ID"/>
<index column="LINK_SQ" type="float"/>
<element column="LINK_ID" type="long"/>
</map>

</class>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 02, 2004 7:10 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This is not possible in SQL, hence not in Hibernate. You would need a vendor specific procedural query, e.g. "select .. connect by..." in Oracle or "select recursive ..." in DB2. Use Session.createSQLQuery(). Another approach is the "nested set model", search Google.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.