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

com.zhuang.data.mybatis.util.SqlBuilderUtils Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
package com.zhuang.data.mybatis.util;

import com.zhuang.data.enums.DbDialect;
import com.zhuang.data.orm.enums.PlaceHolderType;
import com.zhuang.data.orm.mapping.TableMapping;
import com.zhuang.data.orm.sql.SqlBuilder;
import com.zhuang.data.orm.sql.SqlBuilderFactory;
import org.apache.ibatis.mapping.SqlCommandType;

/**
 * @author zhuang
 **/
public class SqlBuilderUtils {

    public static String getSql(DbDialect dbDialect, TableMapping tableMapping, PlaceHolderType placeHolderType, SqlCommandType sqlCommandType) {
        String sql = "";
        SqlBuilder sqlBuilder = SqlBuilderFactory.createSqlBuilder(dbDialect, tableMapping, placeHolderType);
        if (sqlCommandType == SqlCommandType.SELECT) {
            sql = sqlBuilder.buildSelect().getSql();
        } else if (sqlCommandType == SqlCommandType.INSERT) {
            sql = sqlBuilder.buildInsert().getSql();
        } else if (sqlCommandType == SqlCommandType.UPDATE) {
            sql = sqlBuilder.buildUpdate().getSql();
        } else if (sqlCommandType == SqlCommandType.DELETE) {
            sql = sqlBuilder.buildDelete().getSql();
        }
        return sql;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy