首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >映射错误:使用Apache时oracle.sql.TIMESTAMP到java.util.Date

映射错误:使用Apache时oracle.sql.TIMESTAMP到java.util.Date
EN

Stack Overflow用户
提问于 2022-11-23 07:32:48
回答 1查看 37关注 0票数 0

我正在使用java的Apache框架,在该框架中,我使用类型为timestamp的列从oracle获取数据。当我试图将它映射到java.util.Date类型的变量时,它会抛出下面提到的错误。

代码语言:javascript
复制
Caused by: java.lang.IllegalArgumentException:
Could not find a suitable setter for property lastupdated as there isn't a setter method with same type oracle.sql.TIMESTAMP nor type conversion possible: 
No type converter available to convert from type oracle.sql.TIMESTAMP to the required type java.util.Date with value "2022-11-16 19:04:27.067"

有人能帮我吗?

我尝试使用以下java数据类型-

  1. java.util.Date
  2. oracle.sql.TIMESTAMP
  3. java.sql.Timestamp

但错误仍然是一样的。

EN

回答 1

Stack Overflow用户

发布于 2022-11-25 18:21:41

创建一个camel转换器并添加它,camel上下文注释可以更改为spring + camel或quarkus + camel,这是基本的camel注释。

代码语言:javascript
复制
@Converter(generateLoader = true)
public class DateConvertor {
    @Converter
    public static java.sql.Timestamp toTimeStamp(oracle.sql.TIMESTAMP timestamp) {
        return timestamp.timestampValue()
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74543157

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档