use of com.mendmix.mybatis.metadata.TableMetadata in project jeesuite-libs by vakinge.
the class DeleteByPrimaryKeyBuilder method buildSQL.
@Override
String buildSQL(EntityMetadata entityMapper, boolean selective) {
// 从表注解里获取表名等信息
TableMetadata tableMapper = entityMapper.getTable();
ColumnMetadata idColumn = entityMapper.getIdColumn();
SQL sql = new SQL().DELETE_FROM(tableMapper.getName()).WHERE(idColumn.getColumn() + "=#{" + idColumn.getProperty() + "}");
return sql.toString();
}
use of com.mendmix.mybatis.metadata.TableMetadata in project jeesuite-libs by vakinge.
the class InsertBuilder method buildSQL.
@Override
String buildSQL(EntityMetadata entityMapper, boolean selective) {
// 从表注解里获取表名等信息
TableMetadata table = entityMapper.getTable();
Set<ColumnMetadata> columns = entityMapper.getColumns();
StringBuilder fieldBuilder = new StringBuilder(SqlTemplate.TRIM_PREFIX);
StringBuilder prppertyBuilder = new StringBuilder(SqlTemplate.TRIM_PREFIX);
if (!entityMapper.autoId()) {
/* 用户输入自定义ID */
fieldBuilder.append(entityMapper.getIdColumn().getColumn()).append(",");
prppertyBuilder.append("#{").append(entityMapper.getIdColumn().getProperty()).append("},");
}
for (ColumnMetadata column : columns) {
if (column.isId() || !column.isInsertable()) {
continue;
}
String fieldExpr = SqlTemplate.wrapIfTag(column.getProperty(), column.getColumn(), !selective);
String propertyExpr = SqlTemplate.wrapIfTag(column.getProperty(), "#{" + column.getProperty() + "}", !selective);
fieldBuilder.append(fieldExpr);
fieldBuilder.append(selective ? "\n" : ",");
prppertyBuilder.append(propertyExpr);
prppertyBuilder.append(selective ? "\n" : ",");
}
if (!selective) {
fieldBuilder.deleteCharAt(fieldBuilder.length() - 1);
prppertyBuilder.deleteCharAt(prppertyBuilder.length() - 1);
}
fieldBuilder.append(SqlTemplate.TRIM_SUFFIX);
prppertyBuilder.append(SqlTemplate.TRIM_SUFFIX);
String sql = String.format(SqlTemplate.INSERT, table.getName(), fieldBuilder.toString(), prppertyBuilder.toString());
return sql;
}
use of com.mendmix.mybatis.metadata.TableMetadata in project jeesuite-libs by vakinge.
the class InsertListBuilder method buildSQL.
@Override
String buildSQL(EntityMetadata entityMapper, boolean selective) {
// 从表注解里获取表名等信息
TableMetadata table = entityMapper.getTable();
Set<ColumnMetadata> columns = entityMapper.getColumns();
StringBuilder fieldBuilder = new StringBuilder("(");
StringBuilder prppertyBuilder = new StringBuilder("(");
if (!entityMapper.autoId()) {
fieldBuilder.append(entityMapper.getIdColumn().getColumn()).append(",");
prppertyBuilder.append("#{item.").append(entityMapper.getIdColumn().getProperty()).append("},");
}
for (ColumnMetadata column : columns) {
if (column.isId() || !column.isInsertable()) {
continue;
}
String fieldExpr = SqlTemplate.wrapIfTag(column.getProperty(), column.getColumn(), true);
String propertyExpr = SqlTemplate.wrapIfTag(column.getProperty(), "#{item." + column.getProperty() + "}", true);
fieldBuilder.append(fieldExpr);
fieldBuilder.append(",");
prppertyBuilder.append(propertyExpr);
prppertyBuilder.append(",");
}
fieldBuilder.deleteCharAt(fieldBuilder.length() - 1);
prppertyBuilder.deleteCharAt(prppertyBuilder.length() - 1);
fieldBuilder.append(")");
prppertyBuilder.append(")");
String sql = String.format(SqlTemplate.BATCH_INSERT, table.getName(), fieldBuilder.toString(), prppertyBuilder.toString());
return sql;
}
use of com.mendmix.mybatis.metadata.TableMetadata in project jeesuite-libs by vakinge.
the class SelectByPrimaryKeyBuilder method buildSQL.
@Override
String buildSQL(EntityMetadata entityMapper, boolean selective) {
// 从表注解里获取表名等信息
TableMetadata tableMapper = entityMapper.getTable();
ColumnMetadata idColumn = entityMapper.getIdColumn();
return new SQL().SELECT("*").FROM(tableMapper.getName()).WHERE(idColumn.getColumn() + "=#{" + idColumn.getProperty() + "}").toString();
}
use of com.mendmix.mybatis.metadata.TableMetadata in project jeesuite-libs by vakinge.
the class SelectByPrimaryKeysBuilder method buildSQL.
@Override
String buildSQL(EntityMetadata entityMapper, boolean selective) {
TableMetadata tableMapper = entityMapper.getTable();
ColumnMetadata idColumn = entityMapper.getIdColumn();
String sql = String.format(SqlTemplate.SELECT_BY_KEYS, tableMapper.getName(), idColumn.getColumn());
return sql;
}
Aggregations