我使用MyBatis
写了update crud operation
xml mapper
。
这是我的xml mapper
和parametertype
,
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.tera.mappers.DocumentMapper">
<update id="updateApplicantRequestHistory" parameterType="com.tera.dao.AgentApplicantHistoryUpdateDao">
UPDATE applicant_registration_request_history SET DOCUMENT_ID = #{documentId}, LAST_UPDATED_USER = #{lastUpdatedUser}, LAST_UPDATED_TIME = now()
WHERE APPLICANT_REQUEST_HISTORY_ID = #{requestHistoryId}
</update>
</mapper>
和parameterType,
package com.tera.dao;
import java.io.Serializable;
public class AgentApplicantHistoryUpdateDao implements Serializable {
private int documentId;
private String lastUpdatedUser;
private int requestHistoryId;
public AgentApplicantHistoryUpdateDao(){
}
public int getDocumentId() {
return documentId;
}
public void setDocumentId(int documentId) {
this.documentId = documentId;
}
public String getLastUpdatedUser() {
return lastUpdatedUser;
}
public void setLastUpdatedUser(String lastUpdatedUser) {
this.lastUpdatedUser = lastUpdatedUser;
}
public int getRequestHistoryId() {
return requestHistoryId;
}
public void setRequestHistoryId(int requestHistoryId) {
this.requestHistoryId = requestHistoryId;
}
}
我在服务类中这样称呼了这个映射器,
public void updateApplicantRequestHistory(int documentId, String lastUpdatedUser, int requestHistoryId) {
try {
AgentApplicantHistoryUpdateDao agentApplicantHistoryUpdateDao = new AgentApplicantHistoryUpdateDao();
agentApplicantHistoryUpdateDao.setDocumentId(documentId);
agentApplicantHistoryUpdateDao.setLastUpdatedUser(lastUpdatedUser);
agentApplicantHistoryUpdateDao.setRequestHistoryId(requestHistoryId);
this.documentMapper.updateApplicantRequestHistory(agentApplicantHistoryUpdateDao);
}catch (Exception ex){
ex.printStackTrace();
}
}
调用上述服务方法后,我无法对相关列进行任何更新。也没有任何异常。
有什么事情做不正确吗?您对此事有何看法?