com.tmsps.ne4springboot.orm.SqlServerUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ne4SpringBoot Show documentation
Show all versions of ne4SpringBoot Show documentation
NE For SpringBoot is good :)
The newest version!
package com.tmsps.ne4springboot.orm;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.util.List;
import java.util.Map;
import com.tmsps.ne4springboot.annotation.PK;
import com.tmsps.ne4springboot.orm.model.DataModel;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SqlServerUtil {
public static String getInsSQL(final Class extends DataModel> clazz) {
int i = 0;
StringBuilder sb = new StringBuilder("insert into ");
// 获取表名称
sb.append(ClassUtil.getTableName(clazz)).append("(");
// 获取class中需要映射的属性名
List names = ClassUtil.getPropertyName(clazz);
for (i = 0; i < names.size() - 1; i++) {
// 生成映射的insert 语句
sb.append('[').append(names.get(i)).append("],");
}
sb.append('[').append(names.get(names.size() - 1)).append(']');
sb.append(") values (");
for (i = 0; i < names.size() - 1; i++) {
// 生成映射的占位符
sb.append("? , ");
}
sb.append("?)");
log.debug(sb.toString());
return sb.toString();
}
public static String getTemplateInsSQL(final String tableName,final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy