-->
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: [ hql ] date
PostPosted: Fri Jan 16, 2009 7:48 pm 
Beginner
Beginner

Joined: Fri Apr 23, 2004 6:39 pm
Posts: 23
Hi,

I am working on hibernate 3 and Oracle 9.

I don't know my request doesn't work?

delete from MyObject as m where m.myDate < current_date() - 6;

And also the request nex does not work:
"delete from MyObject as m where m.myDate < " + new Date();



Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2009 12:13 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
different types of date used in DBMS, for eg., 10/21/2008 in DB whereas when u will use new Date() object it returns timestamp. i.e., date & time .

so cast ur date object as like in DB with SimpleDateFormat class.

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2009 3:48 pm 
Beginner
Beginner

Joined: Fri Apr 23, 2004 6:39 pm
Posts: 23
Ok thanks. but what this hql request does not work?

delete from MyObject as m where m.myDate < current_date() - 6 (day);

to have result for now extract 6 days.



Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2009 7:55 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
when you call current_date() it returns date with timestamp info, thatz problem here

_________________
If u feel it will help you, don't forget to rate me....


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.