Skip to content

Commit

Permalink
去掉可能存在列字段的分隔符
Browse files Browse the repository at this point in the history
  • Loading branch information
abel533 committed Jul 13, 2017
1 parent 1bd114b commit 1f14969
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/tk/mybatis/mapper/entity/EntityTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@

import javax.persistence.Table;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* 数据库表
*
* @author liuzh
*/
public class EntityTable {
public static final Pattern DELIMITER = Pattern.compile("^[`\\[\"]?(.*?)[`\\]\"]?$");

private String name;
private String catalog;
private String schema;
Expand Down Expand Up @@ -194,7 +198,13 @@ public ResultMap getResultMap(Configuration configuration) {
}
List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
for (EntityColumn entityColumn : entityClassColumns) {
ResultMapping.Builder builder = new ResultMapping.Builder(configuration, entityColumn.getProperty(), entityColumn.getColumn(), entityColumn.getJavaType());
String column = entityColumn.getColumn();
//去掉可能存在的分隔符
Matcher matcher = DELIMITER.matcher(column);
if(matcher.find()){
column = matcher.group(1);
}
ResultMapping.Builder builder = new ResultMapping.Builder(configuration, entityColumn.getProperty(), column, entityColumn.getJavaType());
if (entityColumn.getJdbcType() != null) {
builder.jdbcType(entityColumn.getJdbcType());
}
Expand Down

0 comments on commit 1f14969

Please sign in to comment.