-->
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.  [ 1 post ] 
Author Message
 Post subject: Distinct collection items when using multiple joins
PostPosted: Wed Mar 26, 2008 11:31 am 
Beginner
Beginner

Joined: Tue Mar 27, 2007 4:54 am
Posts: 47
Hi

I have a problem when nesting joins in a deep graph, eg like this...
Code:
IList<A> res = Session.CreateCriteria(typeof (A))
                .SetFetchMode("BCollection", FetchMode.Join)
                .SetFetchMode("BCollection.CCollection", FetchMode.Join)
                .SetResultTransformer(CriteriaUtil.DistinctRootEntity)
                .List<A>();

...the resulttransformer only "distincting" the root, not the BCollection which will contain multiple duplicates if there are multiple C items. Cannot really find a nice work around either.

The above criteria query using the following mapping...
Code:
<class name="A">
    <id name="Id"
            type="guid"
            unsaved-value="null">
      <generator class="guid.comb" />
    </id>

    <bag name="BCollection"
      cascade="all-delete-orphan"
      inverse="true">
      <key column ="Parent" />
      <one-to-many class="B" />
    </bag>
   
  </class>
  <class name="B">
    <id name="Id"
    type="guid"
    unsaved-value="null">
      <generator class="guid.comb" />
    </id>
    <many-to-one name="Parent"
                class="A"
                 not-null="true"/>

    <bag name="CCollection"
    cascade="all-delete-orphan"
    inverse="true">
      <key column ="Parent" />
      <one-to-many class="C" />
    </bag>
  </class>

  <class name="C">
    <id name="Id"
      type="guid"
      unsaved-value="null">
      <generator class="guid.comb" />
    </id>
    <many-to-one name="Parent"
      class="B"
      not-null="true"/>
  </class>


Anyone?
/Roger


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

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.