]> git.mxchange.org Git - jcontacts-business-core.git/blobdiff - src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java
Rewrite:
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / employee / CompanyEmployee.java
index 31df0b148b209fc4082c86355d93c6dbe0d2c44b..61e09c15eb026d782133734359d9cd2de8ae5c74 100644 (file)
  */
 package org.mxchange.jcontactsbusiness.employee;
 
-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;
@@ -32,6 +32,8 @@ import org.mxchange.jcontactsbusiness.branch.BranchOffice;
 import org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice;
 import org.mxchange.jcontactsbusiness.department.CompanyDepartment;
 import org.mxchange.jcontactsbusiness.department.Department;
+import org.mxchange.jcontactsbusiness.jobposition.EmployeePosition;
+import org.mxchange.jcontactsbusiness.jobposition.JobPosition;
 import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
 
@@ -49,26 +51,18 @@ public class CompanyEmployee implements Employee, Comparable<Employee> {
         */
        private static final long serialVersionUID = 48_959_819_859_812_076L;
 
-       /**
-        * Id number
-        */
-       @Id
-       @Column (name = "employee_id", length = 20, nullable = false, updatable = false)
-       @GeneratedValue (strategy = GenerationType.IDENTITY)
-       private Long employeeId;
-
        /**
         * Branch office the employee works at
         */
        @JoinColumn (name = "employee_branch_id")
-       @OneToOne (targetEntity = CompanyBranchOffice.class, cascade = CascadeType.ALL, orphanRemoval = true)
+       @OneToOne (targetEntity = CompanyBranchOffice.class, cascade = CascadeType.ALL)
        private BranchOffice employeeBranchOffice;
 
        /**
         * Department the employee works at
         */
-       @JoinColumn (name = "employee_department_id", nullable = false)
-       @OneToOne (targetEntity = CompanyDepartment.class, cascade = CascadeType.ALL, optional = false)
+       @JoinColumn (name = "employee_department_id")
+       @OneToOne (targetEntity = CompanyDepartment.class, cascade = CascadeType.ALL)
        private Department employeeDepartment;
 
        /**
@@ -77,6 +71,14 @@ public class CompanyEmployee implements Employee, Comparable<Employee> {
        @Column (name = "employee_email_address", length = 30)
        private String employeeEmailAddress;
 
+       /**
+        * Id number
+        */
+       @Id
+       @Column (name = "employee_id", length = 20, nullable = false, updatable = false)
+       @GeneratedValue (strategy = GenerationType.IDENTITY)
+       private Long employeeId;
+
        /**
         * Employee's business mobile number
         */
@@ -87,16 +89,15 @@ public class CompanyEmployee implements Employee, Comparable<Employee> {
        /**
         * Employee's number
         */
-       @Basic (optional = false)
-       @Column (name = "employee_number", length = 20, nullable = false)
+       @Column (name = "employee_number", length = 20)
        private String employeeNumber;
 
        /**
         * Employee's personal data
         */
        @JoinColumn (name = "employee_personal_data_id", nullable = false, updatable = false)
-       @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false)
-       private Contact employeePersonalData;
+       @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false, fetch = FetchType.EAGER)
+       private transient Contact employeePersonalData;
 
        /**
         * Employee's phone extension (or number if different)
@@ -107,9 +108,9 @@ public class CompanyEmployee implements Employee, Comparable<Employee> {
        /**
         * Employee's position (example: CEO)
         */
-       @Basic (optional = false)
-       @Column (name = "employee_status", length = 50, nullable = false)
-       private String employeePosition;
+       @JoinColumn (name = "employee_position_id")
+       @OneToOne (targetEntity = EmployeePosition.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+       private transient JobPosition employeePosition;
 
        @Override
        public int compareTo (final Employee employee) {
@@ -197,12 +198,12 @@ public class CompanyEmployee implements Employee, Comparable<Employee> {
        }
 
        @Override
-       public String getEmployeePosition () {
+       public JobPosition getEmployeePosition () {
                return this.employeePosition;
        }
 
        @Override
-       public void setEmployeePosition (final String employeePosition) {
+       public void setEmployeePosition (final JobPosition employeePosition) {
                this.employeePosition = employeePosition;
        }
 }