Add fix for serial number search

fixes components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java
syncHierarchicalGrouping
osh 2 years ago
parent 7688aa375d
commit 7d6cfaa3b1

@ -97,7 +97,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
"WHERE DEVICE_TYPE_ID = t.ID " + "WHERE DEVICE_TYPE_ID = t.ID " +
"AND d.ID= i.DEVICE_ID " + "AND d.ID= i.DEVICE_ID " +
"AND i.KEY_FIELD = 'serial' " + "AND i.KEY_FIELD = 'serial' " +
"AND i.VALUE_FIELD = ? " + "AND i.VALUE_FIELD LIKE ? " +
"AND d.TENANT_ID = ? "; "AND d.TENANT_ID = ? ";
isSerialProvided = true; isSerialProvided = true;
} else { } else {
@ -141,7 +141,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIdx = 1; int paramIdx = 1;
if (isSerialProvided) { if (isSerialProvided) {
stmt.setString(paramIdx++, serial); stmt.setString(paramIdx++, "%" + serial + "%");
} }
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
if (isSinceProvided) { if (isSinceProvided) {

@ -98,7 +98,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
"WHERE DEVICE_TYPE_ID = t.ID " + "WHERE DEVICE_TYPE_ID = t.ID " +
"AND d.ID= i.DEVICE_ID " + "AND d.ID= i.DEVICE_ID " +
"AND i.KEY_FIELD = 'serial' " + "AND i.KEY_FIELD = 'serial' " +
"AND i.VALUE_FIELD = ? " + "AND i.VALUE_FIELD LIKE ? " +
"AND d.TENANT_ID = ? "; "AND d.TENANT_ID = ? ";
isSerialProvided = true; isSerialProvided = true;
} else { } else {
@ -142,7 +142,7 @@ public class OracleDeviceDAOImpl extends AbstractDeviceDAOImpl {
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIdx = 1; int paramIdx = 1;
if (isSerialProvided) { if (isSerialProvided) {
stmt.setString(paramIdx++, serial); stmt.setString(paramIdx++, "%" + serial + "%");
} }
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
if (isSinceProvided) { if (isSinceProvided) {

@ -97,7 +97,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
"WHERE DEVICE_TYPE_ID = t.ID " + "WHERE DEVICE_TYPE_ID = t.ID " +
"AND d.ID= i.DEVICE_ID " + "AND d.ID= i.DEVICE_ID " +
"AND i.KEY_FIELD = 'serial' " + "AND i.KEY_FIELD = 'serial' " +
"AND i.VALUE_FIELD = ? " + "AND i.VALUE_FIELD LIKE ? " +
"AND d.TENANT_ID = ? "; "AND d.TENANT_ID = ? ";
isSerialProvided = true; isSerialProvided = true;
} else { } else {
@ -136,7 +136,7 @@ public class PostgreSQLDeviceDAOImpl extends AbstractDeviceDAOImpl {
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIdx = 1; int paramIdx = 1;
if (isSerialProvided) { if (isSerialProvided) {
stmt.setString(paramIdx++, serial); stmt.setString(paramIdx++, "%" + serial + "%");
} }
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
if (isDeviceTypeProvided) { if (isDeviceTypeProvided) {

@ -99,7 +99,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
"WHERE DEVICE_TYPE_ID = t.ID " + "WHERE DEVICE_TYPE_ID = t.ID " +
"AND d.ID= i.DEVICE_ID " + "AND d.ID= i.DEVICE_ID " +
"AND i.KEY_FIELD = 'serial' " + "AND i.KEY_FIELD = 'serial' " +
"AND i.VALUE_FIELD = ? " + "AND i.VALUE_FIELD LIKE ? " +
"AND d.TENANT_ID = ? "; "AND d.TENANT_ID = ? ";
isSerialProvided = true; isSerialProvided = true;
} else { } else {
@ -143,7 +143,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
int paramIdx = 1; int paramIdx = 1;
if (isSerialProvided) { if (isSerialProvided) {
stmt.setString(paramIdx++, serial); stmt.setString(paramIdx++, "%" + serial + "%");
} }
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
if (isSinceProvided) { if (isSinceProvided) {

Loading…
Cancel
Save