diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java index 4c338e29..4f3a6ddb 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/DevicesServiceImpl.java @@ -141,12 +141,22 @@ public List findByIdIn(List ids) { @Override public Devices findByAgentIdAndUdId(int agentId, String udId) { - return lambdaQuery().eq(Devices::getAgentId, agentId).eq(Devices::getUdId, udId).one(); + List devicesList = lambdaQuery().eq(Devices::getAgentId, agentId).eq(Devices::getUdId, udId).list(); + if (devicesList.size() > 0) { + return devicesList.get(0); + } else { + return null; + } } @Override public Devices findByUdId(String udId) { - return lambdaQuery().eq(Devices::getUdId, udId).one(); + List devicesList = lambdaQuery().eq(Devices::getUdId, udId).list(); + if (devicesList.size() > 0) { + return devicesList.get(0); + } else { + return null; + } } @Override