• Post Reply Bookmark Topic Watch Topic
  • New Topic

simple EJB Query ?  RSS feed

 
Hatem Alimam
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys ,
I have a little issue with my EJB query, which I'm trying to get today registered users .

My Query is :

select o from MyUsers o where o.registeredDate=CURRENT_DATE

my problem is that o.registeredDate is Timestamp in MyUsers entity ... so the where clues is not working probably.

so any ideas how can I make my where clues working fine to get today registered users.

and I can't change th o.registeredDate to sql Date .

thanks in advance .

Best regards .
 
giuseppe morreale
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to use a parameter

Query q = select o from MyUsers o where o.registeredDate=?1
q.setParameter(1,new Timestamp(new Date().getTime()));

But this can't get the todays registered user.
if o.registeredDate is a timestamp you must write a between WHERE.

If the user register at 19/jan/2009 18:01 you must select it from

19/jan/2009 00:00 to 19/jan/2009 23:59 (or now timestamp).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!