com.mybatis.jpa.definition.template.InsertSqlTemplate 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 svili
**/
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();
}
}