Thanks, I should read the manual really! Richard
From: [email protected] [mailto:[email protected]] On Behalf Of Yonah Wahrhaftig Sent: 08 April 2010 12:57 To: [email protected] Subject: Re: [nhusers] Restrictions.IsNotEmpty not behaving as expected I'm not absolutely sure about this but it would seem is not empty refers to a collection (one-to-many) whereas you have a one-to-one in your mapping. Try using Restrictions.IsNotNull instead. _____ From: "Richard Wilde" <[email protected]> Date: Thu, 8 Apr 2010 12:20:18 +0100 To: <[email protected]> Subject: [nhusers] Restrictions.IsNotEmpty not behaving as expected I think I have found a bug OR something else that may not be quite right.... I am trying to find all BobMember that has a photo, this works fine ICriteria criteria = Session .CreateCriteria(typeof(BobMember)) .CreateAlias("Images", "Images", JoinType.InnerJoin) .Add(Restrictions.Like("Images.Photo", "%.jpg")) .AddOrder(new RandomOrder()) .SetMaxResults(10); The following code throws the following exception "Property path [Domain.Model.Entities.BobMemberImages.Photo] does not reference a collection... ICriteria criteria = Session .CreateCriteria(typeof(BobMember)) .CreateAlias("Images", "Images", JoinType.InnerJoin) .Add(Restrictions.IsNotEmpty("Images.Photo")) .AddOrder(new RandomOrder()) .SetMaxResults(10); Is there something in the usage of IsNotEmpty that is different from Like? My mappings are:- <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Domain.Model.Entities" assembly="Domain.Model"> <class name="Domain.Model.Entities.BobMember, Domain.Model" table="memberview" mutable="false" where="(IsDeleted=0)"> <id name="Id" column="id" unsaved-value="0"> <generator class="identity" /> </id> <property name="ClubId" column="idClub" /> <one-to-one name="Images" class="BobMemberImages" foreign-key="id"/> </class> </hibernate-mapping> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Domain.Model.Entities" assembly="Domain.Model"> <class name="Domain.Model.Entities.BobMemberImages, Domain.Model" table="MembersImages"> <id name="Id" column="id" unsaved-value="0"> <generator class="identity" /> </id> <property name="Photo" /> <property name="Logo" /> </class> </hibernate-mapping> namespace Domain.Model.Entities { public class BobMember : Entity { public virtual int ClubId { get; protected set; } public virtual BobMemberImages Images { get; set; } } } namespace Domain.Model.Entities { public class BobMemberImages : Entity { public virtual string Photo { get; set; } public virtual string Logo { get; set; } } } Many Thanks Richard -- 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. -- 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. -- 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.
