I found why this wasn't working - i had mapped two different classes to the same database table and NH didn't seem to like that. When I reverted back to just once class it worked again
On Aug 26, 10:24 am, JamesSpibey <[email protected]> wrote: > Hi, > > I'm seeing some rather strange results with the following query > (NHibernate 2.1) > > Function ImageExists() As Boolean > > Dim crit = GetSession.CreateCriteria(Of ProductImage)() > > crit.SetProjection(Projections.RowCount()) > > Return crit.UniqueResult(Of Integer)() > 0 > > End Function > > When this code is executed, I get the following exception > > 'query did not return a unique result: 2' > > at NHibernate.Impl.AbstractQueryImpl.UniqueElement(IList list) > at NHibernate.Impl.CriteriaImpl.UniqueResult() > at NHibernate.Impl.CriteriaImpl.UniqueResult[T]() > at MyCode > > Clearly this is incorrect because I am just doing a COUNT(*) with no > grouping so there should only be one result. However, when I check in > NHPROF, I actually see the following > > SELECT count(* ) as y0_ > FROM PRODUCT_IMAGE this_ > SELECT count(* ) as y0_ > FROM PRODUCT_IMAGE this_ > > So I see the same query executed twice! I can't see anything wrong > with my mappings etc so I wonder if anyone might know what's causing > this? > > Thanks > > James --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
