NutzCN Logo
问答 关于localdatetime存储的问题
发布于 1222天前 作者 qq_c0a91281 1245 次浏览 复制 上一个帖子 下一个帖子
标签:

实体:
```java
@Getter
@Table("dim_channel_copy")
public class DimChannel {
@Column(hump = true, value = "date")
private LocalDateTime localDateTime;
...setget
}

存储

...
NutDao nutDao = new NutDao(dataSource);
DimChannel dimChannel = new DimChannel();
dimChannel.setLocalDateTime(LocalDateTime.now());
nutDao.insert(dataSource);
```

报错:

Exception in thread "main" org.nutz.dao.DaoException: org.nutz.castor.FailToCastObjectException: Fail to cast 'Wed Aug 18 18:27:02 CST 2021' to <long>
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:140)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:93)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:82)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:56)
	at org.nutz.dao.impl.NutDao.insert(NutDao.java:149)
	at org.myorg.quickstart.dim.DimChannel.main(DimChannel.java:72)
Caused by: org.nutz.castor.FailToCastObjectException: Fail to cast 'Wed Aug 18 18:27:02 CST 2021' to <long>
	at org.nutz.castor.castor.String2Number.cast(String2Number.java:45)
	at org.nutz.castor.castor.String2Number.cast(String2Number.java:19)
	at org.nutz.castor.Castors.cast(Castors.java:253)
	at org.nutz.castor.Castors.castTo(Castors.java:317)
	at org.nutz.dao.jdbc.Jdbcs$Adaptor$7.set(Jdbcs.java:420)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:306)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:159)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:126)
	... 7 more
1 回复

格式不太好,也没发现删除按钮,请移到=》https://nutz.cn/yvr/t/4amqhppqggjfbr3g1rm9g2lh47

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