I have a composite component which has a many-to-one reference.
class MyComposite
{
SomeEntity ManyToOne { get; set; }
SomeOtherUserType Value { get; set; }
}
For ease of mapping, I've made a custom ICompositeUserType which encompases
this component:
class MyCompositeUserType : ICompositeUserType
{
// ...
private static readonly IType[] _propertyTypes = new[]
{
new
ManyToOneType("SomeEntity"),
new
CustomType(typeof(SomeOtherUserType))
};
// ...
}
Now, I have a collection of composite-elements which include this
component:
<class name="Container">
...
<set name="Pairings"
cascade="all-delete-orphan"
generic="true"
lazy="false"
table="Pairings"
fetch="join">
<key column="ContainerId" />
<composite-element class="Pair">
<property name="Item1" type="mycomposite" lazy="false">
<column name="Entity1Id" />
<column name="Amount1" />
</property>
<property name="Item2" type="mycomposite" lazy="false">
<column name="Entity2Id" />
<column name="Amount2" />
</property>
<property name="Tag" column="Tag" />
</composite-element>
</set>
</class>
When I query on the Container class, the Pairings set is loaded eagerly, as
designed, however, I then get an N+1 select on the SomeEntity which forms a
part of the MyCompositeUserType. I want to load those entities along with
the join on the Pairings set.
How can this be specified?
Thanks,
-rory
(Copied from:
http://stackoverflow.com/questions/10359957/how-do-i-avoid-an-n1-select-and-specify-fetch-strategy-for-nhibernate-user
-
feel free to answer there to get your sweet, sweet points)
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.