实例如下:
/**
* 根据设备类型ID以及设备类型编码来判断是否有与之同编码的其他设备类型
*/
@Override
public boolean hasSameDCatCode(String DCatCode,String DCatId) throws DAOException {
boolean flag =false;
List<TIbmsInfoDeviceCategory> lists=new ArrayList<TIbmsInfoDeviceCategory>();
StringBuffer hql=new StringBuffer(" from TIbmsInfoDeviceCategory t where t.DCatCode= ?");
List<Object> paramList=new ArrayList<Object>();
paramList.add(DCatName);
lists=DevCatDao.find(hql.toString(),paramList.toArray());
if(lists.size()>0){
//再for循环判断是否是自己,不跟自己比
for(TIbmsInfoDeviceCategory list:lists){
if(list.getDCatId().equals(DCatId)){
flag=false;
}else{
flag=true;
}
}
}
return flag;
}