use of org.nutz.dao.entity.annotation.Index in project nutz by nutzam.
the class AnnotationEntityMaker method _evalEntityIndexes.
private void _evalEntityIndexes(NutEntity<?> en, TableIndexes indexes) {
for (Index idx : indexes.value()) {
NutEntityIndex index = new NutEntityIndex();
index.setUnique(idx.unique());
index.setName(idx.name());
for (String indexName : idx.fields()) {
EntityField ef = en.getField(indexName);
if (null == ef) {
throw Lang.makeThrow("Fail to find field '%s' in '%s' by @Index(%s:%s)", indexName, en.getType().getName(), index.getName(), Lang.concat(idx.fields()));
}
index.addField(ef);
}
en.addIndex(index);
}
}
Aggregations