比如
```java
@Table("my_corp")
@TableIndexes({@Index(fields = "name",name = "${table}_name")})
public class Corp {
...
}
```
生成索引名称为 my_corp_name
再进一步,能否给@Index增加自动生成name的机制,
name = 表名_字段1_字段2....
这样
翻了翻代码,事实上有类似的功能
public Sql createIndexSql(Entity<?> en, EntityIndex index) {
StringBuilder sb = new StringBuilder();
if (index.isUnique())
sb.append("Create UNIQUE Index ");
else
sb.append("Create Index ");
if (index.getName().contains("$"))
sb.append(TableName.render(new CharSegment(index.getName())));
else
sb.append(index.getName());
sb.append(" ON ").append(en.getTableName()).append("(");
for (EntityField field : index.getFields()) {
if (field instanceof MappingField) {
MappingField mf = (MappingField) field;
sb.append(mf.getColumnNameInSql()).append(',');
} else {
throw Lang.makeThrow(DaoException.class,
"%s %s is NOT a mapping field, can't use as index field!!",
en.getClass(),
field.getName());
}
}
sb.setCharAt(sb.length() - 1, ')');
return Sqls.create(sb.toString());
}