-->
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: How to get uninicialized Timestamp?
PostPosted: Fri Jan 16, 2009 9:26 am 
Newbie

Joined: Mon Sep 24, 2007 9:35 am
Posts: 4
I have table in database (mysql) with column endDate Timestamp. It can ce null, but as a default database puts such value '0000-00-00 00:00:00'. In mapping file I have:
<property column="END_DATE" name="endDate" type="timestamp"/>,
but if I want to get record from this table I receive such error:
Caused by: java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 5 to TIMESTAMP.

How can I solve this?


Top
 Profile  
 
 Post subject: Re: How to get uninicialized Timestamp?
PostPosted: Sat May 30, 2009 11:09 pm 
Newbie

Joined: Sat May 30, 2009 11:06 pm
Posts: 2
Add this to your hibernate.cfg.xml:

<property name="hibernate.connection.zeroDateTimeBehavior">convertToNull</property>

That will convert the zero dates to nulls and hibernate won't choke.


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.