]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
Some cascade/fetch cleanups:
authorRoland Haeder <roland@mxchange.org>
Fri, 11 Mar 2016 21:02:18 +0000 (22:02 +0100)
committerRoland Haeder <roland@mxchange.org>
Fri, 11 Mar 2016 21:02:18 +0000 (22:02 +0100)
- 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)

lib/juser-core.jar
src/org/mxchange/jcontactsbusiness/CompanyContact.java
src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java
src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java
src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java
src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java
src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java

index 22b1352719e70921cb178edbaf2f44438454ab4e..7dad4a093ec73a3f597125d3068b39e293fae567 100644 (file)
Binary files a/lib/juser-core.jar and b/lib/juser-core.jar differ
index 3c8c477fae25a63317bce0ad0b5f476c3a2dbb44..53a00bf27ebd6d4bbd18470052d63b6aefc7fbfc 100644 (file)
@@ -103,7 +103,7 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
         * User owner instance
         */
        @JoinColumn (name = "company_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 contactUserOwner;
 
        /**
index 33c3be9146f8e71eb8b5fe7a5b40c7933ea4d407..a5c0815378200b5a2a56ca435dcd0d141f5896c1 100644 (file)
@@ -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;
@@ -67,7 +66,7 @@ public class CompanyBasicData implements BusinessBasicData, Comparable<BusinessB
         * User owner instance
         */
        @JoinColumn (name = "company_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 basicUserOwner;
 
        /**
@@ -95,7 +94,7 @@ public class CompanyBasicData implements BusinessBasicData, Comparable<BusinessB
         * Company's main fax numbers: +ccxxxxxxxxxx
         */
        @JoinColumn (name = "company_fax_number_id")
-       @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+       @OneToOne (targetEntity = FaxNumber.class, cascade = CascadeType.ALL)
        private DialableFaxNumber companyFaxNumber;
 
        /**
@@ -123,7 +122,7 @@ public class CompanyBasicData implements BusinessBasicData, Comparable<BusinessB
         * Company's main phone number: +ccxxxxxxxxxx
         */
        @JoinColumn (name = "company_phone_number_id")
-       @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+       @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL)
        private DialableLandLineNumber companyPhoneNumber;
 
        /**
index 000a8715fb1112d5b3e146ff714fe90bbea0349d..227ac7fba0d7d010ee7b0fa3b55b9b7ec5ecbb7a 100644 (file)
@@ -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;
@@ -73,7 +72,7 @@ public class CompanyBranchOffice implements BranchOffice, Comparable<BranchOffic
         * Branch office's country code
         */
        @JoinColumn (name = "branch_country_id", nullable = false)
-       @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.MERGE, optional = false, fetch = FetchType.EAGER)
+       @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
        private Country branchCountry;
 
        /**
@@ -142,7 +141,7 @@ public class CompanyBranchOffice implements BranchOffice, Comparable<BranchOffic
         * User owner instance
         */
        @JoinColumn (name = "branch_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 branchUserOwner;
 
        /**
index f4153bc39142ec470fb96207e9abfd8a92899442..83a420be3fddb4155d1a20157acca69fa149ea57 100644 (file)
@@ -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;
@@ -75,7 +74,7 @@ public class CompanyDepartment implements Department, Comparable<Department> {
         * 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> {
         * 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<Department> {
         * 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
index b60b21516a04f50f9d553c3f0e2a71e2d9a75226..af2261f05c82035c032e569c6544be880ac12f0b 100644 (file)
@@ -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> {
         * 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> {
         * 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
index 1ee51a331ceb278b5572de88b9dad34c2224ccb0..bbd15da32fe622805a1ea4d9ca64775e09a20450 100644 (file)
@@ -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<Hea
         * Headquarter's country code
         */
        @JoinColumn (name = "headquarters_country_id", nullable = false)
-       @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.MERGE, optional = false, fetch = FetchType.EAGER)
+       @OneToOne (targetEntity = CountryData.class, cascade = CascadeType.REFRESH, optional = false)
        private Country headquartersCountry;
 
        /**
@@ -128,7 +127,7 @@ public class CompanyHeadQuartersData implements HeadQuartersData, Comparable<Hea
         * User owner instance
         */
        @JoinColumn (name = "headquarters_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 headquartersUserOwner;
 
        /**
index 4964bba754f1cc024e9847264a62c0f5ce379c09..2df7718295c541202703e42dfd23c31ea72f23d8 100644 (file)
@@ -74,7 +74,7 @@ public class CompanyLogo implements BusinessLogo, Comparable<BusinessLogo> {
         * 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