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

com.mybatis.jpa.definition.template.InsertSqlTemplate Maven / Gradle / Ivy

There is a newer version: 2.5.1
Show newest version
package com.mybatis.jpa.definition.template;

import com.mybatis.jpa.util.ColumnMetaResolver;
import com.mybatis.jpa.util.PersistentUtil;
import java.lang.reflect.Field;
import org.apache.ibatis.jdbc.SQL;

/**
 * @author sway.li
 **/
public class InsertSqlTemplate implements SqlTemplate {

  @Override
  public String parseSQL(final Class type) {
    return new SQL() {
      {
        INSERT_INTO(PersistentUtil.getTableName(type));
        for (Field field : PersistentUtil.getPersistentFields(type)) {
          if (PersistentUtil.insertable(field)) {
            VALUES(PersistentUtil.getColumnName(field),
                ColumnMetaResolver.resolveSqlPlaceholder(field));
          }
        }
      }
    }.toString();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy