如何处理应用程序级别的“值'0000-00-00'不能表示为java.sql.Timestamp”错误?
Posted
技术标签:
【中文标题】如何处理应用程序级别的“值\'0000-00-00\'不能表示为java.sql.Timestamp”错误?【英文标题】:How to deal with "Value '0000-00-00' can not be represented as java.sql.Timestamp" error at application level?如何处理应用程序级别的“值'0000-00-00'不能表示为java.sql.Timestamp”错误? 【发布时间】:2015-03-05 23:53:04 【问题描述】:我正在使用 Spring 3.2.11.RELEASE、Hibernate 4.3.6.Final、JPA 2.1 和 mysql 5.5.37。我的 InnoDB 表中有一个 DATETIME 列,该列偶尔设置为“0000-00-00 00:00:00”。 Hibernate 无法处理这个问题,我想为其配置一种方法来处理我的应用程序中的问题,而不是乱搞服务器上的设置(运行 JBoss 7.1.3.Final)。这个我试过了
<entry key="hibernate.connection.zeroDateTimeBehavior" value="convertToNull" />
在我的应用程序上下文文件中,但无济于事。以下是我配置数据源的完整方式。例外如下。有什么方法可以处理我的应用程序中的异常(而不是服务器上的设置)?
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="org.mainco.subco" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="dataSource" ref="dataSource"/>
<property name="jpaPropertyMap" ref="jpaPropertyMap" />
</bean>
<util:map id="jpaPropertyMap">
<entry key="hibernate.show_sql" value="false" />
<entry key="hibernate.hbm2ddl.auto" value="validate"/>
<entry key="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<entry key="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
<entry key="hibernate.cache.region.factory_class" value="org.hibernate.cache.ehcache.EhCacheRegionFactory"/>
<entry key="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
<entry key="hibernate.cache.use_second_level_cache" value="true" />
<entry key="hibernate.cache.use_query_cache" value="false" />
<entry key="hibernate.generate_statistics" value="false" />
<entry key="hibernate.connection.zeroDateTimeBehavior" value="convertToNull" />
</util:map>
<bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<jee:jndi-lookup jndi-name="java:jboss/datasources/MySqlDS" id="dataSource" expected-type="javax.sql.DataSource"/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
异常堆栈跟踪如下……
17:37:39,548 INFO [org.directwebremoting.log.accessLog] (http-/0.0.0.0:8080-2) Method execution failed: : javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Could not read entity state from ResultSet : EntityKey[org.mainco.subco.mypackage.domain.mypackage#BELVUEADMINTESTLP1]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763) [hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) [hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458) [hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:67) [hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
at org.mainco.subco.mypackage.repo.mypackageDaoImpl.getClas-s-roomAssessmentAssignmentsByProducts(mypackageDaoImpl.java:1020) [core-76.0.0-SNAPSHOT.jar:]
at org.mainco.subco.report.service.ReportServiceImpl.getCourseUnitsForAdminUnitAssessment(ReportServiceImpl.java:1516) [core-76.0.0-SNAPSHOT.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [classes.jar:1.6.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [classes.jar:1.6.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [classes.jar:1.6.0_65]
at java.lang.reflect.Method.invoke(Method.java:597) [classes.jar:1.6.0_65]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) [spring-aop-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183) [spring-aop-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) [spring-aop-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:51) [spring-aop-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161) [spring-aop-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96) [spring-tx-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260) [spring-tx-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94) [spring-tx-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91) [spring-aop-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [spring-aop-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) [spring-aop-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at com.sun.proxy.$Proxy403.getCourseUnitsForAdminUnitAssessment(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [classes.jar:1.6.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [classes.jar:1.6.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [classes.jar:1.6.0_65]
at java.lang.reflect.Method.invoke(Method.java:597) [classes.jar:1.6.0_65]
at org.directwebremoting.impl.CreatorModule$1.doFilter(CreatorModule.java:229) [dwr-3.0.0-rc2.jar:]
at org.mainco.subco.ebook.mvc.filter.DwrSessionCheckingFilter.doFilter(DwrSessionCheckingFilter.java:77) [classes:]
at org.directwebremoting.impl.CreatorModule$1.doFilter(CreatorModule.java:223) [dwr-3.0.0-rc2.jar:]
at org.mainco.subco.ebook.mvc.filter.DwrSessionCheckingFilter.doFilter(DwrSessionCheckingFilter.java:77) [classes:]
at org.directwebremoting.impl.CreatorModule$1.doFilter(CreatorModule.java:223) [dwr-3.0.0-rc2.jar:]
at org.directwebremoting.impl.CreatorModule.executeMethod(CreatorModule.java:241) [dwr-3.0.0-rc2.jar:]
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:379) [dwr-3.0.0-rc2.jar:]
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:332) [dwr-3.0.0-rc2.jar:]
at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:104) [dwr-3.0.0-rc2.jar:]
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:120) [dwr-3.0.0-rc2.jar:]
at org.directwebremoting.spring.DwrController.handleRequestInternal(DwrController.java:234) [dwr-3.0.0-rc2.jar:]
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) [spring-webmvc-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) [spring-webmvc-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919) [spring-webmvc-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851) [spring-webmvc-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953) [spring-webmvc-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855) [spring-webmvc-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.1.Final.jar:1.0.1.Final]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829) [spring-webmvc-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.1.Final.jar:1.0.1.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:]
at org.owasp.csrfguard.CsrfGuardFilter.doFilter(CsrfGuardFilter.java:79) [csrfguard-3.0.0.jar:3.0.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) [spring-security-web-3.1.4.RELEASE.jar:3.1.4.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343) [spring-web-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260) [spring-web-3.2.11.RELEASE.jar:3.2.11.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.17.Final.jar:]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:165) [jboss-as-web-7.1.3.Final.jar:7.1.3.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.17.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372) [jbossweb-7.0.17.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.17.Final.jar:]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679) [jbossweb-7.0.17.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.17.Final.jar:]
at java.lang.Thread.run(Thread.java:695) [classes.jar:1.6.0_65]
Caused by: org.hibernate.exception.GenericJDBCException: Could not read entity state from ResultSet : EntityKey[org.mainco.subco.mypackage.domain.mypackage#BELVUEADMINTESTLP1]
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.loadFromResultSet(EntityReferenceInitializerImpl.java:339) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.hydrateEntityState(EntityReferenceInitializerImpl.java:251) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.plan.exec.process.internal.AbstractRowReader.readRow(AbstractRowReader.java:107) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.plan.exec.internal.EntityLoadQueryDetails$EntityLoaderRowReader.readRow(EntityLoadQueryDetails.java:255) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.plan.exec.process.internal.ResultSetProcessorImpl.extractResults(ResultSetProcessorImpl.java:129) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:138) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:102) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:186) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4126) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:503) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:468) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:213) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:275) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1070) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:989) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:716) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.type.EntityType.resolve(EntityType.java:502) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:170) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:144) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1114) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.Loader.processResultSet(Loader.java:972) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:920) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2553) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2539) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2369) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.Loader.list(Loader.java:2364) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:496) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573) [hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449) [hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
... 86 more
Caused by: java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074) [mysql-connector-java-5.1.22-bin.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988) [mysql-connector-java-5.1.22-bin.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974) [mysql-connector-java-5.1.22-bin.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919) [mysql-connector-java-5.1.22-bin.jar:]
at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:1061) [mysql-connector-java-5.1.22-bin.jar:]
at com.mysql.jdbc.ByteArrayRow.getTimestampFast(ByteArrayRow.java:127) [mysql-connector-java-5.1.22-bin.jar:]
at com.mysql.jdbc.ResultSetImpl.getTimestampInternal(ResultSetImpl.java:6591) [mysql-connector-java-5.1.22-bin.jar:]
at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:6191) [mysql-connector-java-5.1.22-bin.jar:]
at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:6229) [mysql-connector-java-5.1.22-bin.jar:]
at org.jboss.jca.adapters.jdbc.WrappedResultSet.getTimestamp(WrappedResultSet.java:1528)
at org.hibernate.type.descriptor.sql.TimestampTypeDescriptor$2.doExtract(TimestampTypeDescriptor.java:75) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:267) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:338) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2969) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.loader.plan.exec.process.internal.EntityReferenceInitializerImpl.loadFromResultSet(EntityReferenceInitializerImpl.java:324) [hibernate-core-4.3.6.Final.jar:4.3.6.Final]
... 120 more
【问题讨论】:
zeroDateTimeBehavior=true
应该可以工作。 MySQL 在连接字符串中有类似的选项。
【参考方案1】:
我对 MySQL 5.6 和 mysql-connector-java 5.1.36 有同样的问题。
我切换到 JDBC 驱动程序 mariadb-java-client 1.1.9,这似乎有效。
【讨论】:
以上是关于如何处理应用程序级别的“值'0000-00-00'不能表示为java.sql.Timestamp”错误?的主要内容,如果未能解决你的问题,请参考以下文章
Azure 通知中心:安装 ID 以及如何处理应用程序的卸载