-->
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.  [ 3 posts ] 
Author Message
 Post subject: Oracle sysdate and between where clause
PostPosted: Thu Jan 15, 2004 5:16 am 
Beginner
Beginner

Joined: Thu Jan 01, 2004 11:36 am
Posts: 23
Location: Belgium
Hi,

suppose we have an Oracle table

create table test (
named_interval varchar2(20),
begindate date,
enddate date
);

selecting all the record which are currently 'actif' would be

select named_interval from test
where sysdate between begindate and enddate

how can I do this in hibernate ? I looked at the Criteria.between clause but this does the opposite and sysdate will not be accepted by hibernate as it is no 'test'-table column.

something like:

public Some getAll() {
Criteria criteria = session.createCriteria(Some.class);
criteria.add(Expression.between("sysdate", "begindate", "enddate"));
List myItems = criteria.list();
...
}

Jan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 6:05 am 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
Why not doing the query yourself and using the JVM system date instead of Oracle's SYSDATE function ?

The answer may depend on how initializes the begindate and enddate... If it is your Java application, then it is valid to use the solution above.
If it is the database (using triggers or whatever) - then indeed you have to select according to the database current time...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 7:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You can do this using straight HQL.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.