-->
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.  [ 2 posts ] 
Author Message
 Post subject: java.time.OffsetDateTime to MS SQL Server datetimeoffset
PostPosted: Thu Jun 23, 2016 10:03 am 
Newbie

Joined: Thu Jun 23, 2016 9:59 am
Posts: 1
We have Date fields with type java.time.OffsetDateTime (JAVA8) in our models. We are using Microsoft SQL Server as our database. And Table columns in database are of type datetimeoffset. We are using Hibernate as ORM in our application. But we are not able to store our java.time.OffsetDateTime fields to sql server datetimeoffset column using Hibernate.

Please let us know how can we achieve this?


Top
 Profile  
 
 Post subject: Re: java.time.OffsetDateTime to MS SQL Server datetimeoffset
PostPosted: Thu Jun 23, 2016 10:26 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The OffsetDateTimeType constructor is defined like this:

Code:
public OffsetDateTimeType() {
     super( TimestampTypeDescriptor.INSTANCE, OffsetDateTimeJavaDescriptor.INSTANCE );
}


This means that the expected SQL type is TIMESTAMP, not the SQL Server-specific datetimeoffset.
What you need to do so to create a new Type, possibly extending OffsetDateTimeType.

You can check this blog post to see an example of how you can do it.
Or you can use this custom UserType described in this StackOverflow question.


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