-->
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.  [ 1 post ] 
Author Message
 Post subject: Use of "current_timestamp()" in Hibernate v2
PostPosted: Tue Dec 08, 2009 3:17 pm 
Newbie

Joined: Tue Dec 08, 2009 2:48 pm
Posts: 1
I have to modify some Java Code, and a portion of it uses Hibernate to query an
Oracle database. I am VERY familiar with Oracle, fairly familiar with Java and
Eclipse(used for this project), and very little with Hibernate.

I have read some of the documentation on Hibernate, and I believe I found the function that I needed, but I want to make sure it will work as I believe it should.

The existing query string is as follows.

requestList = session.find("select r from Hl7OutRequest as r join fetch r.hl7OutStatus as s where s.statusCd = ? order by r.requestId", status, Hibernate.STRING);

The problem is that the field "requestId" has a cardinality of 5, we have Oracle Standard
Edition, and the index on this field is a standard BTree index. Hence, the Oracle CBO
will tell Oracle to do a full table scan every time this executes. FYI, there are over
1,000,000 rows.

There is another field in the table called "CREATE_DATE"(mapped as "createDate" in the
HBM XML file). So, I have modified the code to include the concept of a "lag Time", which
is read from the XML configuration file for the application. In a nutshell, it will tell Oracle
to only look for messages with a status of "whatever status chose(1, 2, 3, 4, or 5) and created after a certain date/time. I have also created a composite index on the table with
"CREATE_DATE" and "STATUS_ID".

My question is whether or not HQL will accept the following. The "getQueueLagTime()"
call will return a string copy of the float variable this is the number of hours in
days unit. So, if I want thirty minutes, it will be the string "0.021". So, it
is basically "current_timestamp() - 0.021". Will HQL parse this correctly? It
does not need to be a bind variable, because it will always be the same the
whole time it is running. It runs nonstop.

requestList = session.find("select r from Hl7OutRequest as r join fetch r.hl7OutStatus as s
where r.createDate >= (current_timestamp() - " +
MessageGeneratorProperties.getInstance().getQueueLagTime() +
") and s.statusCd = ? order by r.requestId", status,
Hibernate.STRING);

Sorry for such a boring newbie question!


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

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.