添加一條記錄要考慮某個屬性值是否存在的問題,如果只從數據庫查詢判斷,會出現是要編輯就會提示編號是否存在,
算法設計如下:
代碼示例:
public boolean MedicineTypeCodeIsRepeat(String code,String id) {
BeGenService<MedicineType> begen = (BeGenService<MedicineType>)getBean("beGenService");
Map queryMap = new HashMap();
queryMap.put("medicTypeCode", code);
List<MedicineType> temp = begen.getTList(MedicineType.class, queryMap);
if(temp!=null && temp.size()>0){
if(!temp.get(0).getId().equals(id)){
return true;
}
}
return false;
}