NutzCN Logo
问答 nutz-plugins-spring-boot-starter dao用localdate和localtime的值查询报错
发布于 596天前 作者 ethanyuen 2460 次浏览 复制 上一个帖子 下一个帖子
标签:

org.nutz.castor.FailToCastObjectException: Fail to cast from <java.time.LocalDate> to <java.sql.Timestamp> for {2023-05-05}]

6 回复

什么版本的starter?
什么类型的数据库?
什么版本的数据库驱动程序?
有没有具体的case?

nutz版本

org.nutz
nutz-plugins-spring-boot-starter
1.r.68.v20201205

数据库mysql5.7
驱动

mysql
mysql-connector-java
8.0.27
runtime

例子
dao.fetch("test", Cnd.where("test",">", LocalDate.now()))

还是不行。

 06-02 08:48:30 [main] DEBUG org.nutz.dao.impl.sql.run.NutDaoExecutor -SELECT * FROM system_log  WHERE createTime<? LIMIT 0, 1 
    |          1 |
    |------------|
    | 2023-06-02 |
  For example:> "SELECT * FROM system_log  WHERE createTime<'2023-06-02' LIMIT 0, 1 "
| 06-02 08:48:30 [main] DEBUG com.alibaba.druid.pool.PreparedStatementPool -{conn-10002, pstmt-20028} enter cache
| 06-02 08:48:30 [main] ERROR org.ethanyuen.springboot.module.BaseModule -args:null
| 06-02 08:48:30 [main] ERROR org.ethanyuen.springboot.module.BaseModule -null
org.nutz.castor.FailToCastObjectException: Fail to cast from <java.time.LocalDate> to <java.sql.Timestamp> for {2023-06-02}
	at org.nutz.castor.Castors.cast(Castors.java:263)
	at org.nutz.castor.Castors.castTo(Castors.java:317)
	at org.nutz.dao.jdbc.Jdbcs$Adaptor$14.set(Jdbcs.java:583)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:272)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:59)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:65)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:63)
	at org.nutz.plugins.cache.dao.DaoCacheInterceptor._exec(DaoCacheInterceptor.java:28)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:188)
	at org.nutz.plugins.cache.dao.DaoCacheInterceptor.filter(DaoCacheInterceptor.java:18)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:63)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:138)
	at org.nutz.spring.boot.dao.SpringDaoRunner._run(SpringDaoRunner.java:23)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:86)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:242)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:254)
	at org.nutz.dao.impl.NutDao.fetch(NutDao.java:770)
	at org.nutz.dao.impl.NutDao.fetch(NutDao.java:760)
	at org.ethanyuen.springboot.SpringbootApplication.init(SpringbootApplication.java:49)
	at org.ethanyuen.springboot.SpringbootApplication.main(SpringbootApplication.java:40)
Caused by: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
	at java.sql.Timestamp.valueOf(Timestamp.java:204)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.nutz.lang.born.MethodCastingBorning.born(MethodCastingBorning.java:22)
	at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
	at org.nutz.lang.Mirror.born(Mirror.java:1029)
	at org.nutz.castor.castor.Object2Object.cast(Object2Object.java:12)
	at org.nutz.castor.Castors.cast(Castors.java:253)
	... 20 common frames omitted

还有一个问题,程序打包后不能自动更新表是怎么回事,在idea运行可以的

打包成jar包的时候找不到实体类

添加回复
请先登陆
回到顶部