Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Thinkingcao opened this issue Aug 24, 2018 · 0 comments

Comments

@Thinkingcao
Copy link

Thinkingcao commented Aug 24, 2018

异常日志:

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);
    }`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant