From: Roland Haeder Date: Fri, 11 Mar 2016 21:02:18 +0000 (+0100) Subject: Some cascade/fetch cleanups: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1574ec998e02ba76f0675d6798a8557190367ce9;p=jcontacts-business-core.git Some cascade/fetch cleanups: - CascadeType.MERGE is basicly an UPDATE statement, it needs to be REFRESH (from database to local entity object) - Fetch strategy EAGER is default, no need to specify it - updated jar(s) --- diff --git a/lib/juser-core.jar b/lib/juser-core.jar index 22b1352..7dad4a0 100644 Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ diff --git a/src/org/mxchange/jcontactsbusiness/CompanyContact.java b/src/org/mxchange/jcontactsbusiness/CompanyContact.java index 3c8c477..53a00bf 100644 --- a/src/org/mxchange/jcontactsbusiness/CompanyContact.java +++ b/src/org/mxchange/jcontactsbusiness/CompanyContact.java @@ -103,7 +103,7 @@ public class CompanyContact implements BusinessContact, Comparable { * Connection to company contact */ @JoinColumn (name = "department_company_id", nullable = false, updatable = false) - @ManyToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL, optional = false, fetch = FetchType.EAGER) + @ManyToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL, optional = false) private BusinessContact departmentCompany; /** @@ -98,7 +97,7 @@ public class CompanyDepartment implements Department, Comparable { * Department lead employee */ @JoinColumn (name = "department_lead_id", nullable = false) - @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER) + @OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL) private Employee departmentLead; /** @@ -112,7 +111,7 @@ public class CompanyDepartment implements Department, Comparable { * User owner instance */ @JoinColumn (name = "department_user_id", nullable = false, updatable = false) - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false) + @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false) private User departmentUserOwner; @Override diff --git a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java index b60b215..af2261f 100644 --- a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java +++ b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java @@ -22,7 +22,6 @@ import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -129,7 +128,7 @@ public class CompanyEmployee implements Employee, Comparable { * Employee's personal data */ @JoinColumn (name = "employee_personal_data_id", nullable = false, updatable = false) - @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false, fetch = FetchType.EAGER) + @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false) private Contact employeePersonalData; /** @@ -142,14 +141,14 @@ public class CompanyEmployee implements Employee, Comparable { * Employee's position (example: CEO) */ @JoinColumn (name = "employee_position_id") - @OneToOne (targetEntity = EmployeePosition.class, cascade = CascadeType.MERGE, fetch = FetchType.EAGER) + @OneToOne (targetEntity = EmployeePosition.class, cascade = CascadeType.REFRESH) private JobPosition employeePosition; /** * User owner instance */ @JoinColumn (name = "employee_user_id", nullable = false, updatable = false) - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false) + @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false) private User employeeUserOwner; @Override diff --git a/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java b/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java index 1ee51a3..bbd15da 100644 --- a/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java +++ b/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java @@ -22,7 +22,6 @@ import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -65,7 +64,7 @@ public class CompanyHeadQuartersData implements HeadQuartersData, Comparable { * Logo uploader user instance */ @JoinColumn (name = "logo_uploader_id", nullable = false, updatable = false) - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.MERGE, optional = false) + @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false) private User logoUploader; @Override