-->
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: how does one pre-fetch a collection of items' sub properties
PostPosted: Tue Aug 14, 2007 12:13 pm 
Newbie

Joined: Mon Aug 13, 2007 8:49 pm
Posts: 9
how does one pre-fetch a collection of items' sub properties?

Query:

from prf_ProfileSection as s
join fetch s.ProfileItemTitles
join fetch s.ProfileItemTitles.ItemAdapter


Mappings:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="LightsCore.prf_ItemAdapter, LT.Profiles.Data" table="prf.ItemAdapter">
      <id name="Id" type="Int32" unsaved-value="null">
         <column name="ItemAdapterID" length="4" sql-type="int" not-null="true" unique="true" index="PK_ItemTitleAdapter"/>
         <generator class="native" />
      </id>
      <property name="AdapterName" type="String">
         <column name="AdapterName" length="50" sql-type="varchar" not-null="true"/>
      </property>
      <property name="DataAdapterTypeName" type="String">
         <column name="DataAdapterTypeName" length="255" sql-type="varchar" not-null="false"/>
      </property>
      <property name="PresenterTypeName" type="String">
         <column name="PresenterTypeName" length="255" sql-type="varchar" not-null="false"/>
      </property>
      <property name="TableName" type="String">
         <column name="TableName" length="255" sql-type="varchar" not-null="false"/>
      </property>
      <!-- many-to-one foreign key relationships -->
      <!-- end of many-to-one foreign keys -->
      <!--<bag name="StdProfileItemTitles" inverse="true" lazy="true" cascade="all-delete-orphan">
         <key column="ItemAdapterID"/>
         <one-to-many class="LightsCore.prf_StdProfileItemTitle, LightsTogether.Profiles.Data"/>
      </bag>-->
      <!--<bag name="ProfileItemTitles" inverse="true" lazy="true" cascade="all-delete-orphan">
         <key column="ItemAdapterID" />
         <one-to-many class="LightsCore.prf_ProfileItemTitle, LightsTogether.Profiles.Data"/>
      </bag>-->
   </class>
   <class name="LightsCore.prf_ProfileItemTitle, LT.Profiles.Data" table="prf.ProfileItemTitle">
      <id name="Id" type="Int32" unsaved-value="null">
         <column name="TitleID" length="4" sql-type="int" not-null="true" unique="true" index="PK_MemberProfileArea"/>
         <generator class="native" />
      </id>
      <property name="TitleName" type="String">
         <column name="TitleName" length="50" sql-type="varchar" not-null="true"/>
      </property>
      <property name="TitleLabelId" type="Int32">
         <column name="Title_LabelId" length="4" sql-type="int" not-null="false"/>
      </property>
      <property name="DescriptionLabelId" type="Int32">
         <column name="Description_LabelId" length="4" sql-type="int" not-null="false"/>
      </property>
      <property name="IsEnable" type="Boolean">
         <column name="IsEnable" length="1" sql-type="bit" not-null="true"/>
      </property>
      <property name="EditOn" type="DateTime">
         <column name="EditOn" length="4" sql-type="smalldatetime" not-null="true"/>
      </property>
      <property name="AddOn" type="DateTime">
         <column name="AddOn" length="4" sql-type="smalldatetime" not-null="true"/>
      </property>
      <property name="EditByID" type="Int32">
         <column name="EditByID" length="4" sql-type="int" not-null="true"/>
      </property>
      <property name="AddByID" type="Int32">
         <column name="AddByID" length="4" sql-type="int" not-null="true"/>
      </property>
      <!-- many-to-one foreign key relationships -->
      <!--<one-to-one name="prf_StdProfileItemTitle" class="LightsCore.prf_StdProfileItemTitle, LightsTogether.Profiles.Data">
         <column name="TitleID" length="4" sql-type="int" not-null="true" unique="true" index="PK_MemberProfileArea"/>
      </one-to-one>-->
      <many-to-one name="ProfileSection" class="LightsCore.prf_ProfileSection, LT.Profiles.Data">
         <column name="SectionID" length="4" sql-type="int" not-null="true"/>
      </many-to-one>
      <one-to-one name="ItemAdapter" class="LightsCore.prf_ItemAdapter, LightsTogether.Profiles.Data">
      </one-to-one>
      <!-- end of many-to-one foreign keys -->
      <!--<bag name="ProfileItemPicks" inverse="true" lazy="true" cascade="all-delete-orphan">
         <key column="TitleID"/>
         <one-to-many class="LightsCore.prf_ProfileItemPick, LightsTogether.Profiles.Data"/>
      </bag>-->
      <!--<bag name="ProfileItems" inverse="true" lazy="true" cascade="all-delete-orphan">
         <key column="TitleID"/>
         <one-to-many class="LightsCore.prf_ProfileItem, LightsTogether.Profiles.Data"/>
      </bag>-->
   </class>
   <class name="LightsCore.prf_ProfileSection, LightsTogether.Profiles.Data" table="prf.ProfileSection">
      <id name="Id" type="Int32" unsaved-value="null">
         <column name="SectionID" length="4" sql-type="int" not-null="true" unique="true" index="PK_MemProfileSection"/>
         <generator class="native" />
      </id>
      <property name="SectionName" type="String">
         <column name="SectionName" length="50" sql-type="varchar" not-null="true"/>
      </property>
      <property name="TitleLabelId" type="Int32">
         <column name="Title_LabelId" length="4" sql-type="int" not-null="false"/>
      </property>
      <property name="DescriptionLabelId" type="Int32">
         <column name="Description_LabelId" length="4" sql-type="int" not-null="false"/>
      </property>
      <property name="IsEnable" type="Boolean">
         <column name="IsEnable" length="1" sql-type="bit" not-null="true"/>
      </property>
      <property name="EditOn" type="DateTime">
         <column name="EditOn" length="4" sql-type="smalldatetime" not-null="true"/>
      </property>
      <property name="AddOn" type="DateTime">
         <column name="AddOn" length="4" sql-type="smalldatetime" not-null="true"/>
      </property>
      <property name="EditByID" type="Int32">
         <column name="EditByID" length="4" sql-type="int" not-null="true"/>
      </property>
      <property name="AddByID" type="Int32">
         <column name="AddByID" length="4" sql-type="int" not-null="true"/>
      </property>
      <!-- many-to-one foreign key relationships -->
      <!--<many-to-one name="prf_ProfileGroup" class="LightsCore.prf_ProfileGroup, LightsTogether.Profiles.Data">
         <column name="GroupID" length="4" sql-type="int" not-null="true"/>
      </many-to-one>-->
      <!-- end of many-to-one foreign keys -->
      <bag name="ProfileItemTitles" inverse="true" lazy="true" cascade="all-delete-orphan">
         <key column="SectionID"/>
         <one-to-many class="LightsCore.prf_ProfileItemTitle, LightsTogether.Profiles.Data"/>
      </bag>
   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 14, 2007 12:25 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
I don't think that is possible with HQL. Have you tried using a Criteria query?


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.