These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Help with hql query logic flow
PostPosted: Sun Apr 15, 2007 1:51 am 
Newbie

Joined: Mon Nov 07, 2005 10:09 pm
Posts: 9
Location: Milwaukee
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

_________________
Jim Geurts
CEO/Founder, Bia Creations
http://biacreations.com
Office: 414.213.1903
Fax: 414.294.3702


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.