All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.dengchen2020.mybatis.methods.SelectByIdForUpdateMethod Maven / Gradle / Ivy

There is a newer version: 0.0.28
Show newest version
package io.github.dengchen2020.mybatis.methods;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import io.github.dengchen2020.mybatis.base.BaseMybatisRepository;
import org.apache.ibatis.mapping.MappedStatement;

import java.io.Serializable;

/**
 * 根据id查询并加锁
 * @author dengchen
 * @since 2024/6/22
 */
public class SelectByIdForUpdateMethod extends AbstractMethod {

    public SelectByIdForUpdateMethod(String methodName) {
        super(methodName);
    }

    @Override
    public MappedStatement injectMappedStatement(Class mapperClass, Class modelClass, TableInfo tableInfo) {
        String sql = "SELECT "+tableInfo.getAllSqlSelect()+" FROM " + tableInfo.getTableName() + " WHERE id = #{id} FOR UPDATE";
        return addSelectMappedStatementForTable(BaseMybatisRepository.class, languageDriver.createSqlSource(configuration, sql, Serializable.class), tableInfo);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy