com.mybatis.jpa.definition.template.UpdateSqlTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mybatis-jpa Show documentation
Show all versions of mybatis-jpa Show documentation
The plugins for mybatis, in order to provider the ability to handler jpa.
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 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();
}
}