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

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

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 svili
 **/
public class UpdateSqlTemplate implements SqlTemplate {

  @Override
  public String parseSQL(final Class type) {
    return new SQL() {
      {
        UPDATE(PersistentUtil.getTableName(type));
        for (Field field : PersistentUtil.getPersistentFields(type)) {
          if (PersistentUtil.updatable(field)) {
            SET(PersistentUtil.getColumnName(field) + " = " + ColumnMetaResolver
                .resolveSqlPlaceholder(field));
          }
        }
      }
    }.toString();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy