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: hibernate +mysql + date fields
PostPosted: Tue Feb 09, 2010 10:29 pm 
Newbie

Joined: Mon Feb 08, 2010 10:40 am
Posts: 4
hi! i´m newbe in hibernate and I traying to work with 2 related tables, but there´s a problem and I can´t find what is wrong.
when i traying to map date, datetime or timestamp fields from mysql i have problems. I change that fields types and the mappings without any results. Is always the same error.
could not execute query.
Caused by: Cannot convert value '0000-00-00' from column 7 to TIMESTAMP.!!!
someone can help me?
what´s wrong?
tanks in advance!

Richard


Top
 Profile  
 
 Post subject: Re: hibernate +mysql + date fields
PostPosted: Wed Feb 10, 2010 3:56 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
'0000-00-00' is not a valid date and it can of course not be converted to a timestamp. But you may tell the JDBC driver to convert such dates to null by setting zeroDateTimeBehavior=convertToNull in the connection url. For example:

Code:
jdbc:mysql://localhost/test?zeroDateTimeBehavior=convertToNull


More information can be found at http://dev.mysql.com/doc/refman/5.1/en/ ... rties.html


Top
 Profile  
 
 Post subject: Re: hibernate +mysql + date fields
PostPosted: Wed Feb 10, 2010 10:49 am 
Newbie

Joined: Mon Feb 08, 2010 10:40 am
Posts: 4
that's a good notice!
i will see the information atached
thanks!

Richard


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.