From: Roland Haeder <roland@mxchange.org>
Date: Fri, 9 Oct 2015 12:24:02 +0000 (+0200)
Subject: Continued:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=59e7ac6da6501ee530803130fcf1f0b996e01ba3;p=jcontacts-business-core.git

Continued:
- setting to much to unique was not good ... :-(
Signed-off-by:Roland Häder <roland@mxchange.org>
---

diff --git a/src/org/mxchange/jcontactsbusiness/CompanyContact.java b/src/org/mxchange/jcontactsbusiness/CompanyContact.java
index 781fd46..ea8e6f3 100644
--- a/src/org/mxchange/jcontactsbusiness/CompanyContact.java
+++ b/src/org/mxchange/jcontactsbusiness/CompanyContact.java
@@ -52,14 +52,14 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
 	/**
 	 * Reference to basic data
 	 */
-	@JoinColumn (name = "company_basic_data_id", nullable = false, updatable = false, unique = true)
+	@JoinColumn (name = "company_basic_data_id", nullable = false, updatable = false)
 	@OneToOne (targetEntity = CompanyBasicData.class, optional = false)
 	private BusinessBasicData basicBusinessData;
 
 	/**
 	 * Reference to employee branches
 	 */
-	@JoinColumn (name = "company_branches_id", nullable = false, updatable = false, unique = true)
+	@JoinColumn (name = "company_branches_id", nullable = false, updatable = false)
 	@OneToMany (targetEntity = CompanyBranchOffice.class)
 	private List<BranchOffice> branches;
 
@@ -67,7 +67,7 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
 	 * Id number
 	 */
 	@Id
-	@Column (name = "company_contact_id", length = 20, nullable = false, unique = true, updatable = false)
+	@Column (name = "company_contact_id", length = 20, nullable = false, updatable = false)
 	@GeneratedValue (strategy = GenerationType.IDENTITY)
 	private Long companyContactId;
 
@@ -81,14 +81,14 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
 	/**
 	 * Reference to employee list
 	 */
-	@JoinColumn (name = "company_employees_id", nullable = false, updatable = false, unique = true)
+	@JoinColumn (name = "company_employees_id", nullable = false, updatable = false)
 	@OneToMany (targetEntity = CompanyEmployee.class)
 	private List<Employee> employees;
 
 	/**
 	 * Reference to headquarters data
 	 */
-	@JoinColumn (name = "company_headquarters_data_id", nullable = false, updatable = false, unique = true)
+	@JoinColumn (name = "company_headquarters_data_id", nullable = false, updatable = false)
 	@OneToOne (targetEntity = CompanyHeadQuartersData.class, optional = false)
 	private HeadQuartersData headQuartersData;
 
diff --git a/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java b/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
index a632344..5d0d8b9 100644
--- a/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
+++ b/src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
@@ -47,7 +47,7 @@ public class CompanyBasicData implements BusinessBasicData, Comparable<BusinessB
 	 * Id number
 	 */
 	@Id
-	@Column (name = "company_basic_id", length = 20, nullable = false, unique = true, updatable = false)
+	@Column (name = "company_basic_id", length = 20, nullable = false, updatable = false)
 	@GeneratedValue (strategy = GenerationType.IDENTITY)
 	private Long companyBasicId;
 
diff --git a/src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java b/src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java
index c0d0c9e..20113d3 100644
--- a/src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java
+++ b/src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java
@@ -43,7 +43,7 @@ public class CompanyBranchOffice implements BranchOffice, Comparable<BranchOffic
 	 */
 	@Id
 	@GeneratedValue (strategy = GenerationType.IDENTITY)
-	@Column (name = "branch_id", length = 20, nullable = false, unique = true, updatable = false)
+	@Column (name = "branch_id", length = 20, nullable = false, updatable = false)
 	private Long branchId;
 
 	/**
diff --git a/src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java b/src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java
index c8a24dd..236e03c 100644
--- a/src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java
+++ b/src/org/mxchange/jcontactsbusiness/department/CompanyDepartment.java
@@ -17,6 +17,7 @@
 package org.mxchange.jcontactsbusiness.department;
 
 import javax.persistence.Basic;
+import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -24,9 +25,11 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
 import javax.persistence.Table;
 import org.mxchange.jcontactsbusiness.BusinessContact;
 import org.mxchange.jcontactsbusiness.CompanyContact;
+import org.mxchange.jcontactsbusiness.employee.CompanyEmployee;
 import org.mxchange.jcontactsbusiness.employee.Employee;
 
 /**
@@ -55,14 +58,14 @@ public class CompanyDepartment implements Department, Comparable<Department> {
 	 */
 	@Id
 	@GeneratedValue (strategy = GenerationType.IDENTITY)
-	@Column (name = "department_id", length = 20, nullable = false, unique = true, updatable = false)
+	@Column (name = "department_id", length = 20, nullable = false, updatable = false)
 	private Long departmentId;
 
 	/**
 	 * Department lead employee
 	 */
-	@Basic (optional = false)
 	@JoinColumn (name = "department_lead_id", nullable = false)
+	@OneToOne (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
 	private Employee departmentLead;
 
 	/**
diff --git a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java
index 1b96e1f..86d83d8 100644
--- a/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java
+++ b/src/org/mxchange/jcontactsbusiness/employee/CompanyEmployee.java
@@ -50,7 +50,7 @@ public class CompanyEmployee implements Employee, Comparable<Employee> {
 	 * Id number
 	 */
 	@Id
-	@Column (name = "employee_id", length = 20, nullable = false, unique = true, updatable = false)
+	@Column (name = "employee_id", length = 20, nullable = false, updatable = false)
 	@GeneratedValue (strategy = GenerationType.IDENTITY)
 	private Long employeeId;
 
@@ -90,7 +90,7 @@ public class CompanyEmployee implements Employee, Comparable<Employee> {
 	/**
 	 * Employee's personal data
 	 */
-	@JoinColumn (name = "employee_personal_id", nullable = false, unique = true, updatable = false)
+	@JoinColumn (name = "employee_personal_id", nullable = false, updatable = false)
 	@OneToOne (optional = false, targetEntity = UserContact.class)
 	private Contact employeePersonalData;
 
diff --git a/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java b/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java
index 445ea3a..46ca20e 100644
--- a/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java
+++ b/src/org/mxchange/jcontactsbusiness/headquarters/CompanyHeadQuartersData.java
@@ -63,7 +63,7 @@ public class CompanyHeadQuartersData implements HeadQuartersData, Comparable<Hea
 	 * Id number
 	 */
 	@Id
-	@Column (name = "headquarters_id", length = 20, nullable = false, unique = true, updatable = false)
+	@Column (name = "headquarters_id", length = 20, nullable = false, updatable = false)
 	@GeneratedValue (strategy = GenerationType.IDENTITY)
 	private Long headquartersId;
 
diff --git a/src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java b/src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java
index 77c32e5..4ce7ceb 100644
--- a/src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java
+++ b/src/org/mxchange/jcontactsbusiness/logo/CompanyLogo.java
@@ -42,7 +42,7 @@ public class CompanyLogo implements BusinessLogo, Comparable<BusinessLogo> {
 	 */
 	@Id
 	@GeneratedValue (strategy = GenerationType.IDENTITY)
-	@Column (name = "logo_id", length = 20, nullable = false, unique = true, updatable = false)
+	@Column (name = "logo_id", length = 20, nullable = false, updatable = false)
 	private Long logoId;
 
 	@Override