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.  [ 5 posts ] 
Author Message
 Post subject: What's the best approach for end-dating?
PostPosted: Thu Dec 09, 2004 2:55 pm 
Beginner
Beginner

Joined: Mon Nov 22, 2004 8:53 pm
Posts: 23
We do a lot of end-dating. When we end-date something, we set that property on a persistent object to the appservers date (via new Date()) and then commit it. Our queries use sysdate or current_date. The problem is that there is a bit of time drift between our appservers and db server.

One solution is to keep the server's clocks in sync, but then we'd depend on an outside variable to maintain application integrity..not prefrable. The most logical approach is to use the same method at getting the current time. What’s the best approach to do this?

Instead of using sysdate or current_date in our queries, we could pass in the current date from the appserver. The problem is that in a clustered environment, the date could vary.

So what I’d really like to do is to set the property to the value of sysdate or current_date in the db. Is there any way to do this directly with hibernate?

Or any other strategies to solve the problem?

Thanks.
-peter


Hibernate version:2.1.7

Name and version of the database you are using:Oracle9i


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 4:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Sure, why not just grab a database connection from the session factory (sf.openSession().connection()) and query for the current database date?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 10, 2004 12:44 am 
Beginner
Beginner

Joined: Mon Nov 22, 2004 8:53 pm
Posts: 23
steve wrote:
Sure, why not just grab a database connection from the session factory (sf.openSession().connection()) and query for the current database date?


You mean execute a little natice sql and then manually set the end date value?

I was hoping for a bit more portable and automated solution.

-peter


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 11, 2004 12:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Why is this not portable?

Exactly how is Hibernate supposed to know when a given row should be end-dated?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 12:53 pm 
Beginner
Beginner

Joined: Mon Nov 22, 2004 8:53 pm
Posts: 23
steve wrote:
Why is this not portable?


Because I would assume that you're suggesting execute a little sql with the connection, perhaps something like "select sysdate from dual".
I'm not sure but, I'm thinking that's not going to work so well on db's other then oracle.

By "a little more automated", i was hoping not to have to execute any sql manually.

steve wrote:
Exactly how is Hibernate supposed to know when a given row should be end-dated?


I don't expect it to know anything about when to end-date something; that's an application level semantic.
I was hoping that there was a way to have hibernate set a field to the current date, on-demand rather then all the time like <timestamp>.
I've only used end-dating as an example of once case where this kind of feature would solve.


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