-->
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: <timestamp> - Changing default DB function
PostPosted: Thu Dec 23, 2010 8:02 am 
Newbie

Joined: Thu May 27, 2010 4:30 am
Posts: 3
Location: London, UK
Hi,

I'm using MS SQL 2005 and by default hibernate uses current_timestamp to get latest timestamp. I want to use GetUTCDate() function. Is it possible to configure or udpate it? I checked documentation but didn't come across anything.

Code:
<timestamp name="modifiedOn" column="ModifiedOn" source="db"/>


Top
 Profile  
 
 Post subject: Re: <timestamp> - Changing default DB function
PostPosted: Thu Dec 23, 2010 8:06 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
hi,
extend org.hibernate.dialect.SQLServerDialect and override this method:
Code:
public String getCurrentTimestampSelectString() {
      return "select current_timestamp";
   }

Then you configure your custom Dialect http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#configuration-optional-dialects

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: <timestamp> - Changing default DB function
PostPosted: Thu Dec 23, 2010 8:16 am 
Newbie

Joined: Thu May 27, 2010 4:30 am
Posts: 3
Location: London, UK
s.grinovero wrote:


To understant correctly, replace org.hibernate.dialect.SQLServerDialect with my own dialect, say com.sample.dialect.MySQLServerDialect. I have never done this before but won't there be any impact on application?


Top
 Profile  
 
 Post subject: Re: <timestamp> - Changing default DB function
PostPosted: Thu Dec 23, 2010 8:21 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Try it out, hopefully you have tests to verify this.
as long as your implementation extends the default one, and only overrides what you need, the other functions won't be affected.
Of course if you change more things, you will affect more areas.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: <timestamp> - Changing default DB function
PostPosted: Thu Dec 23, 2010 8:36 am 
Newbie

Joined: Thu May 27, 2010 4:30 am
Posts: 3
Location: London, UK
I overrode only getCurrentTimestampSelectString() and it worked as expected. Thanks for that.

Hope there won't be any impact on app.


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.