-->
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.  [ 3 posts ] 
Author Message
 Post subject: Datetime type on SQL Server losting its time information
PostPosted: Fri Aug 29, 2003 2:36 pm 
Newbie

Joined: Wed Aug 27, 2003 5:21 pm
Posts: 7
Hi All,

I am seeing some strange behavior on SQL Server where, when I drop a row into a hibernate-managed table, a column of type "date" is being persisted incorrectly. The date information is being stored fine (year, month, and day), but the time information is being lost.

I tried adding a column tag with sql-type="datetime", but that is giving me a SQLException ("Parameter index out of range") when I try to persist a new row (SchemaExport is okay with it, however).

Any thoughts as to how I can get time information into the DB? I would like to keep my backing date object as a java.util.Date, if possible.

Thanks in advance,
agr32


Top
 Profile  
 
 Post subject: Re: Datetime type on SQL Server losting its time information
PostPosted: Fri Aug 29, 2003 3:03 pm 
Newbie

Joined: Wed Aug 27, 2003 5:21 pm
Posts: 7
agr32 wrote:
Hi All,

I am seeing some strange behavior on SQL Server where, when I drop a row into a hibernate-managed table, a column of type "date" is being persisted incorrectly. The date information is being stored fine (year, month, and day), but the time information is being lost.

I tried adding a column tag with sql-type="datetime", but that is giving me a SQLException ("Parameter index out of range") when I try to persist a new row (SchemaExport is okay with it, however).

Any thoughts as to how I can get time information into the DB? I would like to keep my backing date object as a java.util.Date, if possible.

Thanks in advance,
agr32


FYI, I figured out how to get this to work (thanks to the old forum). You simply remove the type="date" attribute of the property, so your property looks like:

Code:
    <property name="insertedDate"   column="inserted_date">
      <column name="inserted_date" sql-type="datetime" length="8"/>
    </property>


Enjoy,
agr32


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2003 4:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It is the Hibernate "timestamp" type that stores a time.


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