-->
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: Criteeria API
PostPosted: Thu Oct 19, 2006 5:28 am 
Newbie

Joined: Thu Mar 30, 2006 8:23 am
Posts: 19
Location: FRANCE 67
Hello,
I'dlike to make a list of calls made today with the Criteria API

The equivalent sql is :

From Call c where date(c.date_time_begin)=today

but I don't know how to transcribe the function call in the Criteria API

Does anyone know how to do this?

Thanks for your attention


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 7:30 am 
Newbie

Joined: Thu Oct 19, 2006 7:23 am
Posts: 2
You want something along the lines of:

Code:
DateTime today = today();
     
List calls = session.createCriteria(Call.class)
    .add(Restrictions.eq("date_time_begin", today))
    .list();


Assuming that your class is called Call and it has a property of date_time_begin.


Top
 Profile  
 
 Post subject: Re
PostPosted: Thu Oct 19, 2006 8:08 am 
Newbie

Joined: Thu Mar 30, 2006 8:23 am
Posts: 19
Location: FRANCE 67
In this case it searches all the call of now but I want those of the day.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 9:17 am 
Newbie

Joined: Thu Oct 19, 2006 7:23 am
Posts: 2
OK - in that case you need a between clause:

Code:
List calls = session.createCriteria(Call.class)
  .add(Restrictions.between("date_time_begin", startTime, endTime))
  .list();


If this helps please rate :-)


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.