Skip to content

拦截器拦截微信授权,当前用户的粉丝资料在数据库中没有时,就保存粉丝资料,调用系统生成的save()方法,事物失效 #478

Open
@Thinkingcao

Description

异常日志:

SQL: INSERT INTO t_follow( id, open_id, nick_name, sex, country, province, city, headimgurl, unionid, real_name, phone, is_subscribe, subscribe, create_by, create_date, update_by, update_date, remarks, del_flag, sort_index, yl1, yl2, yl3, yl4 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )

Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed

; SQL []; Connection is read-only. Queries leading to data modification are not allowed; nested exception is java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
org.springframework.dao.TransientDataAccessResourceException:

Error updating database. Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed

The error may involve defaultParameterMap

``

     * 保存通过授权拿到的粉丝资料
     * @author cao_wencao
     * @param wxMpUser
     */
    @Transactional(readOnly = false)
    public void saveOauthFollowInfo(WxMpUser wxMpUser){
        Follow follow = new Follow();
        follow.setOpenId(wxMpUser.getOpenId());
        follow.setNickName(wxMpUser.getNickname());
        follow.setSex(wxMpUser.getSexDesc());
        follow.setCountry(wxMpUser.getCountry());
        follow.setProvince(wxMpUser.getProvince());
        follow.setCity(wxMpUser.getCity());
        follow.setHeadimgurl(wxMpUser.getHeadImgUrl());
        String unionid = IdGen.uuid();
        follow.setUnionid(unionid);
        follow.setRealName(EmojiUtils.emojiChange(wxMpUser.getNickname()));
        follow.setIsSubscribe(DictUtils.getDictValue("已关注", "follow_isSubscribe", "1"));
        follow.setSubscribe(new Date());
        
        User user = UserUtils.getUser();
        follow.setCreateDate(new Date());
        follow.setCreateBy(user);
        follow.setUpdateBy(user);
        follow.setUpdateDate(new Date());
        // 新增粉丝
        save(follow);
        // 生成粉丝对应账号
        saveForMemberAndAccount(follow);
    }

   @Transactional(readOnly = false)
    public void save(Follow follow) {
        super.save(follow);
    }`

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions