@Bean
public JpaPollingChannelAdapter reimStgResponseJpaInboundAdapter() {
return Jpa
.inboundAdapter(entityManager)
.nativeQuery(responseQueryString)
//.expectSingleResult(true)
.get();
}
@Bean
public IntegrationFlow reimFeedbackHandle() {
return IntegrationFlows
.from("reimFeedbackChannel")
.handle(msg -> {
try {
dctmHandler.handleReIMFeedback(msg);
} catch (Exception e) {
e.printStackTrace();
}})
.get();
}
.expectSingleResult(true)
返回异常,预期会有1个结果。
本机查询为String responseQueryString = "select * from RMS16DEV.TSC_IM_DOC_HEAD_TEMP where error_ind is not null"
;
入站适配器的msg是一个数组列表,我无法将其强制转换为正确的实体。 jpa入站适配器返回到通道的类型是什么?
public void handleReIMFeedback(Message<?> reimStgRowMsg) throws Exception {
List<TSC_IM_DOC_HEAD_TEMP> list = (List<TSC_IM_DOC_HEAD_TEMP>) reimStgRowMsg.getPayload();
System.out.println( (list.get(0)));
}
给我:
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class java.util.List ([Ljava.lang.Object; and java.util.List are in module java.base of loader 'bootstrap')
at tesco.finance.gss.dctmreim.jpa.handlers.DctmHandlers.handleReIMFeedback(DctmHandlers.java:28)
`
答案 0 :(得分:0)
以下代码解决了该问题:
@Bean
public JpaPollingChannelAdapter reimStgResponseJpaInboundAdapter() {
return Jpa
.inboundAdapter(entityManager)
.nativeQuery(responseQueryString)
.expectSingleResult(true)
.entityClass(TSC_IM_DOC_HEAD_TEMP.class)
.get();
}