use of com.jeesuite.mybatis.crud.helper.EntityMapper in project jeesuite-libs by vakinge.
the class DeleteBuilder method build.
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {
String msId = entity.getMapperClass().getName() + "." + GeneralSqlGenerator.methodDefines.deleteName();
// 从参数对象里提取注解信息
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
// 生成sql
String sql = buildDeleteSql(entityMapper);
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.DELETE);
MappedStatement statement = statementBuilder.build();
configuration.addMappedStatement(statement);
}
use of com.jeesuite.mybatis.crud.helper.EntityMapper 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);
}
}
use of com.jeesuite.mybatis.crud.helper.EntityMapper in project jeesuite-libs by vakinge.
the class GetByPrimaryKeyBuilder method build.
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {
String msId = entity.getMapperClass().getName() + "." + GeneralSqlGenerator.methodDefines.selectName();
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
String sql = buildGetByIdSql(entityMapper);
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.SELECT);
// 将返回值修改为实体类型
MappedStatement statement = statementBuilder.build();
setResultType(configuration, statement, entity.getEntityClass());
configuration.addMappedStatement(statement);
}
use of com.jeesuite.mybatis.crud.helper.EntityMapper in project jeesuite-libs by vakinge.
the class UpdateBuilder method build.
/**
* @param configuration
* @param entity
*/
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {
String[] names = GeneralSqlGenerator.methodDefines.updateName().split(",");
for (String name : names) {
String msId = entity.getMapperClass().getName() + "." + name;
EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
String sql = buildUpdateSql(entityMapper, name.endsWith("Selective"));
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.UPDATE);
MappedStatement statement = statementBuilder.build();
configuration.addMappedStatement(statement);
}
}
Aggregations