mybatis一个update语句,有的字段更新,有的字段偶尔不更新的情况

dubbo分布式系统下Java,mybatis一个update语句,有的字段更新,有的字段偶尔不更新的情况,有没有解决办法?

以下是部分代码片段

@Slf4j
public class UserSaveImpl implements UserSaveFacade {
    
    @Autowired
	private UserSaveService userSaveService;

    @Override
	@Transactional(rollbackFor = Exception.class)
	public void save(Long logId, Long userId, String op) throws Exception {
		try {
			Map re = userSaveService.update(logId, userId, op);
		} catch (Exception e) {
			throw new BizRuleException(e.getMessage());
		}
	}
}


@Slf4j
@Service
public class UserSaveService {

    @Autowired
	private UserSaveMapper userSaveMapper;

    @Autowired
	private LogSaveMapper logSaveMapper;

    public Map update(Long logId, Long userId, String op) throws Exception {
		try {
            Map re = new HashMap();
            LogSave logsave = logSaveMapper.selectByLogId(logId);
            if(!ObjectUtils.isEmpty(logsave)){
                //更新操作
                User user = new User();
                user.setName("张三");
                user.setValidFlag("1");//偶尔会有这个标志更新不掉
                user.setNote("已更新");
                user = userSaveMapper.update(user);
            }
			re.put("logId", logId);
			re.put("user ", user);            
            return re;
        } catch (Exception e) {
            throw new BizRuleException(e.getMessage());
        }    
    }
}

 

其他层的代码也贴一下看看,顺便问一下,就这一个数据更新出问题吗

看代码是没问题的,是不是加了乐观锁啥的
实体上的这个字段加了什么东西?

这个字段java中是String类型,mybatis的xml中是VARCHAR类型,oracle数据库中是VARCHAR2(1)类型

<?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.mapper.UserSaveMapper">
  <resultMap id="BaseResultMap" type="com.po.User">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="validFlag" jdbcType="VARCHAR" property="validFlag" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
  </resultMap>
  <update id="update" parameterType="com.po.User">
    update user
        set name = #{name,jdbcType=VARCHAR},
        validFlag = #{validFlag,jdbcType=VARCHAR},
        create_time = #{createTime,jdbcType=TIMESTAMP},
        modify_time = #{modifyTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>

 

public interface UserSaveMapper{
    int update(User user);
}

 

public class User extends LogBaseVo {
    private static final long serialVersionUID = 1L;
    private Long id;
	private String name;
	private String validFlag;

	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getValidFlag() {
		return validFlag;
	}
	public void setValidFlag(String validFlag) {
		this.validFlag = validFlag;
	}
}