Hibernate Cannot convert value '0000-00-00 00:00:00' from 问题解决

JavaMan_KA 2011-06-14 05:31:19
问题显示:

17:24:09.062 ERROR org.hibernate.util.JDBCExceptionReporter - Cannot convert value '0000-00-00 00:00:00' from column 5 to TIMESTAMP.



原因:在mysql数据库中,如果Date类型的字段为空或者值为'0000-00-00"时,用Hibernate的生成类时就会报错

解决方法:

把jdbc.url变为:

jdbc.url=jdbc:mysql://192.168.3.7:3306/mmcms_pmi?characterEncoding=

UTF-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true

这样就可以了。
...全文
143 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
一溜阳光 2012-11-23
  • 打赏
  • 举报
回复
characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull
New Features FormHttpMessageConverter should support non-String form values [SPR-17645] #22174 spring-jcl routes logging inefficiently against SLF4J with log4j-to-slf4j setup [SPR-17586] #22118 Allow java.time types for setting the Last-Modified header [SPR-17571] #22103 StringHttpMessageConverter should assume charset UTF-8 for application/json [SPR-17568] #22100 NettyDataBufferFactory.join should return original buffer as-is in case of a single element (for compatibility with Netty 4.1.32) [SPR-17560] #22092 Use Netty's optimized UTF-8 encoding if available [SPR-17558] #22090 Equals checks to MediaType.ALL should not be affected the presence of parameters [SPR-17550] #22082 Reactive HTTP header adapters don't print header values in toString [SPR-17546] #22078 Add ability to retrieve associated ClientRequest from WebClientResponseException [SPR-17087] #21624 beetle Bug Fixes HttpHeaders.EMPTY is not immutable [SPR-17633] #22164 UriComponentsBuilder.toUriString() is broken [SPR-17630] #22161 MethodParameter.isOptional() fails with ArrayIndexOutOfBoundsException [SPR-17629] #22160 MockMvcResultMatchers.forwardedUrl argument is not declared as nullable [SPR-17623] #22155 Cannot convert from Collection to RegularEnumSet [SPR-17619] #22151 TomcatHttpHandlerAdapter is not aware of Server[Request|Response]Wrapper [SPR-17611] #22143 ChannelSendOperator does not propagate cancel signal to the server [SPR-17609] #22141 @Value Optional<...> field injection fails in case of registered ConversionService [SPR-17607] #22139 @Profile mishandles "not" operand mixed with "&" [SPR-17606] #22138 SpEL, error parsing big InlineMap [SPR-17605] #22137 Composed RequestPredicates have invalid string representation [SPR-17594] #22126 Regression: IllegalStateException: Ambiguous handler methods is thrown for explicit HEAD mapping [SPR-17593] #22125 Exporting a lazily initialized bean (which implements SelfNaming and is annotated with ManagedResource annotation) gives IllegalStateException [SPR-17592] #22124 MockHttpServletRequest changes Accept-Language header values [SPR-17566] #22098 SpEL variable evaluation fails with NPE against ConcurrentHashMap [SPR-17565] #22097 WebClient logs "Only one connection receive subscriber allowed" when response status is an error [SPR-17564] #22096 Potential resource leak in DataSourceUtils.doGetConnection [SPR-17559] #22091 HibernateTransactionManager (unintentionally) bound to Hibernate 5.2 SharedSessionContractImplementor [SPR-17557] #22089 Spring JavaMailSenderImpl does not show proper message when recipient list is empty [SPR-17540] #22072 'default-lazy-init' attribute is not processed when XSD validation is disabled [SPR-8335] #12983

50,528

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧