Let's say I have a Cat that has two properties: FavoriteKitten,
SecondFavoriteKitten. These kittens are discriminated by their Rank.
When loading a Cat, I want the kitten with the rank of "1" to be
FavoriteKitten, and the kitten with the rank of "2" to be
SecondFavoriteKitten.
The underlying database looks like:
table Cat
----------------
CatId
table Kitten
-----------------
KittenId
CatId
Rank
My mapping looks like:
<class name="Cat">
... other stuff
<one-to-one name="FavoriteKitten" class="Kitten"
property-ref="Cat"
cascade="all-delete-orphan" />
<one-to-one name="SecondFavoriteKitten" class="Kitten"
property-ref="Cat" cascade="all-delete-orphan" />
</class>
My criteria query looks like
Cat cat = sess.CreateCriteria(typeof(Cat))
.CreateAlias("FavoriteKitten", "kt1")
.Add(Expression.Eq("kt1.Rank", "1"))
.CreateAlias("SecondFavoriteKitten", "kt2")
.Add(Expression.Eq("kt2.Rank", "2"))
.UniqueResult();
The trouble is that once loaded, both FavoriteKitten and
SecondFavoriteKitten are the same kitten; the one with a Rank of "2".
Have I left something out of the criteria? Or am I going about this
the wrong way?
Thanks,
Mark
--
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.