Hi All
I'm stumped with what's happening regarding my hql query... I'm using the nHibernate 1.2 CR2 btw and sql server 2005 btw.
Code:
select distinct from Event evt where evt.Owner.Id = :userId
and (
(
(evt.StartDate <= :fromDate and evt.EndDate >= :toDate)
OR (evt.EndDate >= :fromDate and evt.EndDate <= :toDate)
OR (evt.StartDate >= :fromDate and evt.StartDate <= :toDate)
) OR (
evt.Repeat is not null
AND evt.Repeat.Id > 0
AND evt.StartDate <= :toDate
AND (evt.Repeat.HasEndDate = :hasNoEndDate OR evt.Repeat.EndDate > :fromDate)
)
)
I could be wrong, but my thought is that when the following comparison returns true, the rest of the statement shouldn't be evaluated
Code:
(
(evt.StartDate <= :fromDate and evt.EndDate >= :toDate)
OR (evt.EndDate >= :fromDate and evt.EndDate <= :toDate)
OR (evt.StartDate >= :fromDate and evt.StartDate <= :toDate)
)
Unfortunately, I'm seeing that even though that comparison portion returns true, the logic continues to the second comparison which returns false (because the evt.Repeat is null for the object I'm trying to retrieve). I'm hoping that it's just a typo in this query, but if you need more information related to the db structure, hbm markup, or class structure, let me know.
This is what my part of my Event.hbm.xml file looks like:
Code:
<property name="StartDate" type="DateTime" />
<property name="EndDate" type="DateTime" />
<many-to-one
name="Repeat" cascade="all"
class="EventRepeat, NotImportant"
column="EventRepeatId"
/>
<many-to-one name="Owner" cascade="save-update" column="UserId" not-null="true" class="User, NotImportant" />
Any help is appreciated.
Thanks
Jim