Yevgeny Zaspitsky has posted comments on this change. Change subject: core: Move Job, Step to JPA ......................................................................
Patch Set 49: (7 comments) https://gerrit.ovirt.org/#/c/34553/49/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Job.java File backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Job.java: Line 47: @NamedQuery(name = "Job.GetJobsNotInStatus", Line 48: query = "select j from Job j where j.status not in (:status) order by lastUpdateTime DESC"), Line 49: @NamedQuery( Line 50: name = "Job.DeleteCompletedJobs", Line 51: query = "delete from Job j where j.autoCleared = true and ((j.endTime < :failedEndTime and j.status in (:failStatus)) or (j.endTime < :successEndTime and j.status = :successStatus))"), IMHO this line is too long. Pls format that so it'll be more readable. Line 52: @NamedQuery( Line 53: name = "Job.deleteJobOlderThanDateWithStatus", Line 54: query = "delete from Job j where j.autoCleared = true and j.endTime < :sinceDate and j.status in (:statuses)") Line 55: }) Line 51: query = "delete from Job j where j.autoCleared = true and ((j.endTime < :failedEndTime and j.status in (:failStatus)) or (j.endTime < :successEndTime and j.status = :successStatus))"), Line 52: @NamedQuery( Line 53: name = "Job.deleteJobOlderThanDateWithStatus", Line 54: query = "delete from Job j where j.autoCleared = true and j.endTime < :sinceDate and j.status in (:statuses)") Line 55: }) > It would be nice to have some naming convention for NamedQueries, so I woul +1 Line 56: public class Job extends IVdcQueryable implements BusinessEntity<Guid> { Line 57: Line 58: /** Line 59: * Automatic generated serial version ID Line 360: public int hashCode() { : final int prime = 31; : int result = 1; : result = prime * result + ((actionType == null) ? 0 : actionType.hashCode()); : result = prime * result + ((correlationId == null) ? 0 : correlationId.hashCode()); : result = prime * result + ((endTime == null) ? 0 : endTime.hashCode()); : result = prime * result + ((id == null) ? 0 : id.hashCode()); : result = prime * result + (isVisible ? 1231 : 1237); : result = prime * result + ((jobSubjectEntities == null) ? 0 : jobSubjectEntities.hashCode()); : result = prime * result + ((lastUpdateTime == null) ? 0 : lastUpdateTime.hashCode()); : result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode()); : result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); : result = prime * result + ((status == null) ? 0 : status.hashCode()); : result = prime * result + ((steps == null) ? 0 : steps.hashCode()); : result = prime * result + (external ? 1231 : 1237); : result = prime * result + (autoCleared ? 1231 : 1237); : return result; : } I know that isn't your code, but IIUC we agreed on using the immutable business key in equas/hashCode and implement that by using java.util.Objects class. IMHO the best opportunity to do this is JPA-ization of an entity - meaning this patch. Pls use Objects.hash method here. Line 376: return result; Line 377: } Line 378: Line 379: @Override Line 380: public boolean equals(Object obj) { pls see my comment on hashCode method. Line 381: if (this == obj) { Line 382: return true; Line 383: } Line 384: if (obj == null) { https://gerrit.ovirt.org/#/c/34553/49/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/JobSubjectEntity.java File backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/JobSubjectEntity.java: Line 94: jobId = id.getJobId(); Line 95: } Line 96: Line 97: @Override Line 98: public int hashCode() { > Why not use Objects.hash()? +1 Line 99: final int prime = 31; Line 100: int result = 1; Line 101: result = prime * result + ((entityId == null) ? 0 : entityId.hashCode()); Line 102: result = prime * result + ((entityType == null) ? 0 : entityType.hashCode()); Line 115: if (getClass() != obj.getClass()) { : return false; : } > I would prefer to use smallest possible equals() as proposed in Effective J Can't agree more :-) Line 132: } Line 133: } else if (!jobId.equals(other.jobId)) { Line 134: return false; Line 135: } Line 136: return true; > Why not use Objects.equals()? +1 Line 137: } -- To view, visit https://gerrit.ovirt.org/34553 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ifcfda7b055d37c92c1346b100101c27d594d21fb Gerrit-PatchSet: 49 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liran Zelkha <[email protected]> Gerrit-Reviewer: Eli Mesika <[email protected]> Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Liran Zelkha <[email protected]> Gerrit-Reviewer: Martin Mucha <[email protected]> Gerrit-Reviewer: Martin Peřina <[email protected]> Gerrit-Reviewer: Moti Asayag <[email protected]> Gerrit-Reviewer: Oved Ourfali <[email protected]> Gerrit-Reviewer: Roy Golan <[email protected]> Gerrit-Reviewer: Yevgeny Zaspitsky <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
