@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"
;
来自入站适配器的消息是一个数组列表,我无法将其转换为正确的实体。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)
`
以下代码解决了这个问题:
@Bean
public JpaPollingChannelAdapter reimStgResponseJpaInboundAdapter() {
return Jpa
.inboundAdapter(entityManager)
.nativeQuery(responseQueryString)
.expectSingleResult(true)
.entityClass(TSC_IM_DOC_HEAD_TEMP.class)
.get();
}