In my spring boot project, it will occur the following ClassCastException irregularly:
java.lang.ClassCastException: java.sql.Timestamp cannot be cast to com.sybase.jdbc4.jdbc.DateObject at com.sybase.jdbc4.tds.TdsParam.checkDateRange(TdsParam.java:1707) at com.sybase.jdbc4.tds.TdsParam.prepareForSend(TdsParam.java:997) at com.sybase.jdbc4.jdbc.ParamManager.checkParams(ParamManager.java:1192) at com.sybase.jdbc4.tds.Tds.language(Tds.java:1022) at com.sybase.jdbc4.jdbc.SybStatement.sendQuery(SybStatement.java:2557) at com.sybase.jdbc4.jdbc.SybPreparedStatement.sendQuery(SybPreparedStatement.java:3191) at com.sybase.jdbc4.jdbc.SybStatement.execute(SybStatement.java:2829) at com.sybase.jdbc4.jdbc.SybPreparedStatement.execute(SybPreparedStatement.java:1566) at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44) at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.execute(ResultSetReturnImpl.java:128) at org.hibernate.id.IdentityGenerator$InsertSelectDelegate.executeAndExtract(IdentityGenerator.java:87) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:42) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2933) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3524) at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:637) at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282) at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317) at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:318) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:275) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:182) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:113) at org.hibernate.jpa.event.internal.core.JpaPersistEventListener.saveWithGeneratedId(JpaPersistEventListener.java:67) at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132) at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:783) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:768) at sun.reflect.GeneratedMethodAccessor253.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:305) at com.sun.proxy.$Proxy162.persist(Unknown Source)
How-To
When I remove DYNAMIC_PREPARE=false parameter from my datasource url, ClassCastException does not happen so far.
But the root cause is still unknown.