use of org.apache.ibatis.executor.keygen.NoKeyGenerator in project jeesuite-libs by vakinge.
the class InsertBuilder method build.
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {
String[] names = GeneralSqlGenerator.methodDefines.insertName().split(",");
for (String name : names) {
String msId = entity.getMapperClass().getName() + "." + name;
// 从参数对象里提取注解信息
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
// 生成sql
String sql = buildInsertSql(entityMapper, name.endsWith("Selective"));
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.INSERT);
KeyGenerator keyGenerator = entityMapper.autoId() ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
//
statementBuilder.keyGenerator(keyGenerator).keyProperty(//
entityMapper.getIdColumn().getProperty()).keyColumn(entityMapper.getIdColumn().getColumn());
MappedStatement statement = statementBuilder.build();
configuration.addMappedStatement(statement);
}
}
Aggregations