【发布时间】:2018-06-03 23:53:35
【问题描述】:
我有以下从 postgresql 获取数据的路线,但日期对象为空。它无法映射该值
如果跟随我的路线
<route id="instrumentqueryshortsell">
<from uri="direct:restinstumentshortsell"/>
<bean ref="inConverter" method="convert"/>
<setBody>
<simple>select instrumentId as instrument_Id ,amount,easytoborrow as easy_To_Borrow,hardtoborrow as hard_To_Borrow ,datetime as date from instrument_short_sell where instrumentId in (${body}) </simple>
</setBody>
<log message="Running following query ${body} " loggingLevel="DEBUG"/>
<to uri="jdbc:dataSource?useHeadersAsParameters=true&outputClass=<packagename?.InstrumentShortSell" />
</route>
我的 Pojo 类看起来像
import java.time.LocalDateTime;
import org.joda.time.DateTime;
public class InstrumentShortSell {
private String instrumentId;
private long amount;
private boolean easyToBorrow;
private boolean hardToBorrow;
private DateTime date;
public DateTime getDate() {
return date;
}
public void setDate(DateTime date) {
this.date = date;
}
public String getInstrumentId() {
return instrumentId;
}
public void setInstrumentId(String instrumentId) {
this.instrumentId = instrumentId;
}
public long getAmount() {
return amount;
}
public void setAmount(long amount) {
this.amount = amount;
}
public boolean isEasyToBorrow() {
return easyToBorrow;
}
public void setEasyToBorrow(boolean easyToBorrow) {
this.easyToBorrow = easyToBorrow;
}
public boolean isHardToBorrow() {
return hardToBorrow;
}
public void setHardToBorrow(boolean hardToBorrow) {
this.hardToBorrow = hardToBorrow;
}
}
SQL 架构是
CREATE TABLE instrument_short_sell (
instrumentId serial ,
amount INTEGER,
easytoborrow boolean,
hardtoborrow boolean,
datetime timestamp with time zone
) ;
我无法映射 jodadatetime 并且每次它都为空。请帮助我如何在骆驼 jdbc 中映射它
【问题讨论】:
-
您是否尝试使用 java.lang.Date 而不是 org.joda.time.DateTime?
-
java.lang.Date 无论如何都没有时区 java.lang.Date 工作得很好,但我在 Joda datetime 中需要这个
标签: java apache-camel camel-sql