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: fetch="join" ignored?
PostPosted: Sun Dec 14, 2008 6:39 am 
Newbie

Joined: Sun Dec 14, 2008 6:34 am
Posts: 1
For some reason nhibernate is ignoring my mappings on associations to join them instead of using a select. I know this works as I have done it in the past. Has anything changed?

I am getting a list of the forums and thier last post. Basically it is creating 3 post queries for the 3 forums instead of using a left join.

Mappings

Forum.hbm.xml

Code:
<hibernate-mapping auto-import="true" default-lazy="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.2">
  <class name="Falcon.Business.Entities.Forum, Falcon.Business" table="Forums" lazy="true">
    <id name="ID" type="Int32" unsaved-value="0">
      <column name="ID" not-null="true" index="PK_Forums" />
      <generator class="native" />
    </id>
    <property name="Title" column="Title" type="String" not-null="true" />
    <property name="TitleUrl" column="TitleUrl" type="String" not-null="true" />
    <property name="Link" column="Link" type="String" not-null="false" />
    <property name="Body" column="Body" type="StringClob" not-null="false" />
    <property name="BodyParsed" column="BodyParsed" type="StringClob" not-null="false" />
    <property name="Topics" column="Topics" type="Int32" not-null="true" />
    <property name="Posts" column="Posts" type="Int32" not-null="true" />
    <property name="Display" column="Display" type="Int32" not-null="true" />
    <property name="Type" column="Type" type="Falcon.Business.Enums.ForumType, Falcon.Business" not-null="true" />
    <property name="Status" column="Status" type="Falcon.Business.Enums.ForumStatus, Falcon.Business" not-null="true" />
    <many-to-one name="Parent" column="ParentID" class="Falcon.Business.Entities.Forum, Falcon.Business" fetch="join" not-found="ignore" />
    <many-to-one name="LastPost" column="LastPostID" class="Falcon.Business.Entities.ForumPost, Falcon.Business" fetch="join" not-found="ignore" />
  </class>
</hibernate-mapping>


ForumPost.hbm.xml

Code:
<hibernate-mapping auto-import="true" default-lazy="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.2">
  <class name="Falcon.Business.Entities.ForumPost, Falcon.Business" table="ForumsPosts" lazy="true">
    <id name="ID" type="Int32" unsaved-value="0">
      <column name="ID" not-null="true" index="PK_ForumsPosts" />
      <generator class="native" />
    </id>
    <property name="Title" column="Title" type="String" not-null="true" />
    <property name="TitleUrl" column="TitleUrl" type="String" not-null="true" />
    <property name="Body" column="Body" type="StringClob" not-null="true" />
    <property name="BodyParsed" column="BodyParsed" type="StringClob" not-null="true" />
    <property name="Status" column="Status" type="Falcon.Business.Enums.ForumPostStatus, Falcon.Business" not-null="true" />
    <property name="Created" column="Created" type="DateTime" not-null="true" />
    <property name="Updated" column="Updated" type="DateTime" not-null="true" />
    <many-to-one name="Topic" column="TopicID" class="Falcon.Business.Entities.ForumTopic, Falcon.Business" fetch="join" />
    <many-to-one name="Parent" column="ParentID" class="Falcon.Business.Entities.ForumPost, Falcon.Business" fetch="join" not-found="ignore" />
    <many-to-one name="Member" column="MemberID" class="Falcon.Business.Entities.Member, Falcon.Business" fetch="join" />
  </class>
</hibernate-mapping>


Thanks, Mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2008 8:37 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Quote:
I know this works as I have done it in the past.


Do you still use the same hibernate version ? The default value for lazy changed from false to true with 1.2. This might be the reason why your associations are now loaded with a sub select.

_________________
--Wolfgang


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.