Search in sources :

Example 1 with Index

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);
    }
}
Also used : Index(org.nutz.dao.entity.annotation.Index) EntityField(org.nutz.dao.entity.EntityField)

Aggregations

EntityField (org.nutz.dao.entity.EntityField)1 Index (org.nutz.dao.entity.annotation.Index)1