You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Vincent Smith <vi...@outlook.com> on 2015/09/30 20:48:52 UTC
Handling Sql Server datetimeoffset column type
I am using Cayenne 3.0 and Sql Server 2014. I have a column in my sql Server schema with a type of datetimeoffset. My problem is this. Cayenne can convert that column into a java.util.Date without error, but I lose the hours, minutes, and seconds precision. When I try to use java.sql.Timestamp, I get the following error:
java.sql.SQLException: Value 2015-09-28 11:15:18.4170238 -05:00 cannot be converted to TIMESTAMP.
Is there any Cayenne type I can use to convert a datetimeoffset into a java Timestamp or Calendar object and maintain the hours, mins, and seconds?
Re: Handling Sql Server datetimeoffset column type
Posted by Savva Kolbachev <s....@gmail.com>.
Hi Vincent,
I've tried to reproduce your issue, but it works fine for me.
I think you should check your JDBC driver.
I use the following:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
2015-10-01 12:16 GMT+03:00 Andrus Adamchik <an...@objectstyle.org>:
> Never used datetimeoffset. Will need to experiment with it... If the
> driver doesn't read it properly, perhaps we'll can address that in the
> adapter code for SQLServer. I'll put it on my TODO.
>
> Andrus
>
> > On Sep 30, 2015, at 9:48 PM, Vincent Smith <vi...@outlook.com> wrote:
> >
> > I am using Cayenne 3.0 and Sql Server 2014. I have a column in my sql
> Server schema with a type of datetimeoffset. My problem is this. Cayenne
> can convert that column into a java.util.Date without error, but I lose the
> hours, minutes, and seconds precision. When I try to use
> java.sql.Timestamp, I get the following error:
> >
> >
> > java.sql.SQLException: Value 2015-09-28 11:15:18.4170238 -05:00 cannot
> be converted to TIMESTAMP.
> >
> >
> > Is there any Cayenne type I can use to convert a datetimeoffset into a
> java Timestamp or Calendar object and maintain the hours, mins, and seconds?
> >
>
>
Re: Handling Sql Server datetimeoffset column type
Posted by Andrus Adamchik <an...@objectstyle.org>.
Never used datetimeoffset. Will need to experiment with it... If the driver doesn't read it properly, perhaps we'll can address that in the adapter code for SQLServer. I'll put it on my TODO.
Andrus
> On Sep 30, 2015, at 9:48 PM, Vincent Smith <vi...@outlook.com> wrote:
>
> I am using Cayenne 3.0 and Sql Server 2014. I have a column in my sql Server schema with a type of datetimeoffset. My problem is this. Cayenne can convert that column into a java.util.Date without error, but I lose the hours, minutes, and seconds precision. When I try to use java.sql.Timestamp, I get the following error:
>
>
> java.sql.SQLException: Value 2015-09-28 11:15:18.4170238 -05:00 cannot be converted to TIMESTAMP.
>
>
> Is there any Cayenne type I can use to convert a datetimeoffset into a java Timestamp or Calendar object and maintain the hours, mins, and seconds?
>