From: Roland Häder Date: Sun, 10 May 2020 04:37:52 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d919b3d00c9ae871325d1d7f99cee439123b3e87;p=jcontacts-business-core.git Continued: - added to re-add departmentLead in equals()/hashCode() methods but now as Contact and not Employee. In Employee you have a Department instance again, leading to endless recursive calls / stack overflow. Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java b/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java index bc2dcb6..d066b59 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/BusinessDepartment.java @@ -34,13 +34,13 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jcontacts.model.contact.UserContact; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices; import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice; -import org.mxchange.jcontactsbusiness.model.employee.BusinessEmployee; -import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters; @@ -121,11 +121,11 @@ public class BusinessDepartment implements Department { private Long departmentId; /** - * Department lead employee + * Department lead contact data */ @JoinColumn (name = "department_lead_id") - @OneToOne (targetEntity = BusinessEmployee.class, cascade = CascadeType.REFRESH) - private Employable departmentLead; + @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.REFRESH) + private Contact departmentLead; /** * User owner instance @@ -217,6 +217,8 @@ public class BusinessDepartment implements Department { return false; } else if (!Objects.equals(this.getDepartmentId(), department.getDepartmentId())) { return false; + } else if (!Objects.equals(this.getDepartmentLead(), department.getDepartmentLead())) { + return false; } else if (!Objects.equals(this.getDepartmentUserOwner(), department.getDepartmentUserOwner())) { return false; } @@ -299,12 +301,12 @@ public class BusinessDepartment implements Department { } @Override - public Employable getDepartmentLead () { + public Contact getDepartmentLead () { return this.departmentLead; } @Override - public void setDepartmentLead (final Employable departmentLead) { + public void setDepartmentLead (final Contact departmentLead) { this.departmentLead = departmentLead; } @@ -327,6 +329,7 @@ public class BusinessDepartment implements Department { hash = 53 * hash + Objects.hashCode(this.getDepartmentHeadquarter()); hash = 53 * hash + Objects.hashCode(this.getDepartmentId()); hash = 53 * hash + Objects.hashCode(this.getDepartmentI18nKey()); + hash = 53 * hash + Objects.hashCode(this.getDepartmentLead()); hash = 53 * hash + Objects.hashCode(this.getDepartmentUserOwner()); return hash; diff --git a/src/org/mxchange/jcontactsbusiness/model/department/Department.java b/src/org/mxchange/jcontactsbusiness/model/department/Department.java index dcfa260..59fb679 100644 --- a/src/org/mxchange/jcontactsbusiness/model/department/Department.java +++ b/src/org/mxchange/jcontactsbusiness/model/department/Department.java @@ -18,9 +18,9 @@ package org.mxchange.jcontactsbusiness.model.department; import java.io.Serializable; import java.util.Date; +import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontactsbusiness.model.basicdata.BasicData; import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; -import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jusercore.model.user.User; @@ -88,18 +88,18 @@ public interface Department extends Comparable, Serializable { void setDepartmentId (final Long departmentId); /** - * Getter for department lead employee + * Getter for department lead contact *

- * @return Department lead employee + * @return Department lead contact */ - Employable getDepartmentLead (); + Contact getDepartmentLead (); /** - * Setter for department lead employee + * Setter for department lead contact *

- * @param departmentLead Department lead employee + * @param departmentLead Department lead contact */ - void setDepartmentLead (final Employable departmentLead); + void setDepartmentLead (final Contact departmentLead); /** * Getter for department i18n key