내 응용 프로그램에 정말 이상한 버그가 있습니다. ServiceMix에서 응용 프로그램을 실행하면 SimpleJdbcCall에서 가져온 결과에 항상 이전 저장 프로 시저 호출의 모든 이전 값이 포함되어 있다는 문제가 있습니다.Spring JdbcTemplate/SimpleJdbcCall ServiceMix에서 상태 저장
그러나 로컬에서 실행할 때 마지막 값만 저장합니다. (더미 이름)
내 낙타 경로 :
<from ref="cronQuartzEndpoint"/>
<to uri="bean:userDAO?method=listAll"/>
<split>
<simple>${body}</simple>
<to uri="bean:myStoredProcCaller?method=requestAndStoreUserName" />
<to uri="bean:userDAO?method=saveUser" />
</split>
는의가 저장 프로 시저 호출 논리를 보자. 저장 프로 시저가 사용자의 이름을 반환하고 id를 매개 변수로 기다리는 경우를 가정 해 보겠습니다.
public User requestAndStoreUserName(User user) {
LOG.info("userId: " + user.getId());
//I know it's not necessary but I added it to ensure that new RowMapper is generated
mySimpleJdbcCall.returningResultSet(USER_NAME_FIELD, new UserNameRowMapper());
mySimpleJdbcCall.compile();
Map<String, Object> results = mySimpleJdbcCall.execute(user.getId());
List<String> userNames = (List<String>)results.get(USER_NAME_FIELD);
LOG.info("userNames: " + userNames);
if (!userNames .isEmpty()) {
user.setName(userNames.get(0));
}
return user;
}
그리고 내 RowMapper를이 간단하다 : 나는 로컬 내 낙타 경로를 실행하는 경우
private static class UserNameRowMapper implements RowMapper<String> {
@Override
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
return rs.getString(USER_NAME_RESPONSE_FIELD_INDEX);
}
};
로그 :
- userId를 : 1
- 사용자 이름 : [앨리스]
- userId : 2
- userNames : [밥]
로그 경우 ServiceMix에 그것을 실행 :
- userId를 1
- 사용자 이름 : 앨리스]
- userId를 2
- 사용자 이름 : 앨리스 밥]
사용 된 버전의 이슈와 모든 구성은 양쪽에서 동일합니다. 이 아이디어의 논리는 무엇입니까? 고마워요, Gergely