private void evalPks(Class<?> type, MyTable table, Entity<?> entity) {
HashMap<String, EntityField> pkmap = new HashMap<String, EntityField>();
PK pk = type.getAnnotation(PK.class);
if (null != pk) {
for (String pknm : pk.value()){
EntityField ef=entity.getField(pknm);
pkmap.put(pknm, ef);
}
}else{
List<MyField> pkFields=table.getPkFields();
if(pkFields.size()>=2){//判断是不是有多个主键,如果是的话就设置到PKmap中
for (MyField field : pkFields) {
String fieldName=this.getOrmRule().dbField2JavaField(field.getFieldName());
EntityField ef=entity.getField(fieldName);
pkmap.put(fieldName, ef);
}
}
}
Collection<EntityField> pks=pkmap.values();
for (EntityField ef : pks) {
ef.setType(FieldType.PK);
}
}