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.  [ 4 posts ] 
Author Message
 Post subject: How to compare DateTime in NHibernate
PostPosted: Wed Aug 23, 2006 6:39 am 
Newbie

Joined: Tue Jul 18, 2006 2:29 pm
Posts: 10
I have a HQL:

string hql ="Select schedule.ScheduleId From TblSchedule as schedule Where schedule.Classroom.ClassroomId = " + intClassRoomID +" and schedule.StartTime <='" + startime + "'";

How can I compare the field DataTime??
I need change startime to string with format similiar in SQL Server ("YYYYMMDDD")??

Thanks for answers.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 8:00 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Use parameters, don't concatenate data into HQL directly.
Code:
session.CreateQuery("select ... where schedule.StartTime < ?").SetDate(0, startTime).List();


Top
 Profile  
 
 Post subject: Thanks Sergey
PostPosted: Wed Aug 23, 2006 12:35 pm 
Newbie

Joined: Tue Jul 18, 2006 2:29 pm
Posts: 10
It's good solution.
I'm often use HQL with directly parameter....it's ugly....
Thanks sergey for your answer.


Top
 Profile  
 
 Post subject: Thanks Sergey
PostPosted: Wed Aug 23, 2006 12:36 pm 
Newbie

Joined: Tue Jul 18, 2006 2:29 pm
Posts: 10
It's good solution.
Before , I'm often use HQL with directly parameter.......
Thanks sergey for your answer.


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

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.