Refactored Enrolment DAO class

4.x.x
Dileesha Rajapakse 9 years ago
parent 72ffe4e4a4
commit 123ea228ad

@ -42,7 +42,7 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
conn = this.getConnection();
String sql = "INSERT INTO DM_ENROLMENT(DEVICE_ID, OWNER, OWNERSHIP, STATUS, " +
"DATE_OF_ENROLMENT, DATE_OF_LAST_UPDATE, TENANT_ID) VALUES(?, ?, ?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
stmt = conn.prepareStatement(sql, new String[] {"id"});
stmt.setInt(1, deviceId);
stmt.setString(2, enrolmentInfo.getOwner());
stmt.setString(3, enrolmentInfo.getOwnership().toString());
@ -76,7 +76,7 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
String sql = "UPDATE DM_ENROLMENT SET OWNERSHIP = ?, STATUS = ?, " +
"DATE_OF_ENROLMENT = ?, DATE_OF_LAST_UPDATE = ? WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?" +
" AND ID = ?";
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
stmt = conn.prepareStatement(sql, new String[] {"id"});
stmt.setString(1, enrolmentInfo.getOwnership().toString());
stmt.setString(2, enrolmentInfo.getStatus().toString());
stmt.setTimestamp(3, new Timestamp(enrolmentInfo.getDateOfEnrolment()));
@ -109,7 +109,7 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
conn = this.getConnection();
String sql = "UPDATE DM_ENROLMENT SET OWNERSHIP = ?, STATUS = ?, " +
"DATE_OF_ENROLMENT = ?, DATE_OF_LAST_UPDATE = ? WHERE ID = ?";
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
stmt = conn.prepareStatement(sql, new String[] {"id"});
stmt.setString(1, enrolmentInfo.getOwnership().toString());
stmt.setString(2, enrolmentInfo.getStatus().toString());
stmt.setTimestamp(3, new Timestamp(enrolmentInfo.getDateOfEnrolment()));
@ -140,7 +140,7 @@ public class EnrollmentDAOImpl implements EnrollmentDAO {
try {
conn = this.getConnection();
String sql = "DELETE DM_ENROLMENT WHERE DEVICE_ID = ? AND OWNER = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
stmt = conn.prepareStatement(sql, new String[] {"id"});
stmt.setInt(1, deviceId);
stmt.setString(2, currentOwner);
stmt.setInt(3, tenantId);

@ -161,7 +161,7 @@ CREATE TABLE DM_DEVICE_OPERATION_RESPONSE (
OPERATION_ID NUMBER(10) NOT NULL,
OPERATION_RESPONSE BLOB DEFAULT NULL,
CONSTRAINT PK_DM_DEVICE_OP_RESPONSE PRIMARY KEY (ID),
CONSTRAINT FK_DM_DEVICE_OP_RES_DEVICE FOREIGN KEY (DEVICE_ID) REFERENCES
CONSTRAINT FK_DM_DEVICE_OP_RES_DEVICE FOREIGN KEY (ENROLMENT_ID) REFERENCES
DM_DEVICE (ID),
CONSTRAINT FK_DM_DEVICE_OP_RES_OPERATION FOREIGN KEY (OPERATION_ID) REFERENCES
DM_OPERATION (ID)

Loading…
Cancel
Save