]> git.mxchange.org Git - jcontacts-business-core.git/commitdiff
A @OneToMany annotation always causes that in the target entity's table the column...
authorRoland Haeder <roland@mxchange.org>
Wed, 21 Oct 2015 09:32:20 +0000 (11:32 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 21 Oct 2015 09:32:20 +0000 (11:32 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/jcontactsbusiness/BusinessContact.java
src/org/mxchange/jcontactsbusiness/CompanyContact.java
src/org/mxchange/jcontactsbusiness/basicdata/CompanyBasicData.java
src/org/mxchange/jcontactsbusiness/branch/BranchOffice.java
src/org/mxchange/jcontactsbusiness/branch/CompanyBranchOffice.java

index 277439f5659590f6b3c65cdb63439742119c4255..ca70aa5130f3ab98ead9159623c7ed0d739e8b1d 100644 (file)
@@ -49,14 +49,14 @@ public interface BusinessContact extends Serializable {
         * <p>
         * @return Branches list
         */
-       List<BranchOffice> getBranches ();
+       List<BranchOffice> getBrancheOffices ();
 
        /**
         * Setter for branches list
         * <p>
         * @param branches Branches list
         */
-       void setBranches (final List<BranchOffice> branches);
+       void setBrancheOffices (final List<BranchOffice> branches);
 
        /**
         * Getter for company contact person
index 57142c5d957b53722351027f7627eb28dbeac19b..c36f20024b486cd4dbb8b3cd948e16bb7d4ae4ed 100644 (file)
@@ -28,10 +28,10 @@ import javax.persistence.JoinColumn;
 import javax.persistence.OneToMany;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
+import javax.persistence.Transient;
 import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
 import org.mxchange.jcontactsbusiness.basicdata.CompanyBasicData;
 import org.mxchange.jcontactsbusiness.branch.BranchOffice;
-import org.mxchange.jcontactsbusiness.branch.CompanyBranchOffice;
 import org.mxchange.jcontactsbusiness.employee.CompanyEmployee;
 import org.mxchange.jcontactsbusiness.employee.Employee;
 import org.mxchange.jcontactsbusiness.headquarters.CompanyHeadQuartersData;
@@ -59,11 +59,10 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
        private BusinessBasicData basicBusinessData;
 
        /**
-        * Reference to employee branches
+        * Reference to company branch offfices
         */
-       @JoinColumn (name = "company_branches_id", nullable = false, updatable = false)
-       @OneToMany (targetEntity = CompanyBranchOffice.class, cascade = CascadeType.ALL)
-       private List<BranchOffice> branches;
+       @Transient
+       private List<BranchOffice> brancheOffices;
 
        /**
         * Reference to contact person
@@ -130,13 +129,13 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
        }
 
        @Override
-       public List<BranchOffice> getBranches () {
-               return this.branches;
+       public List<BranchOffice> getBrancheOffices () {
+               return this.brancheOffices;
        }
 
        @Override
-       public void setBranches (final List<BranchOffice> branches) {
-               this.branches = branches;
+       public void setBrancheOffices (final List<BranchOffice> brancheOffices) {
+               this.brancheOffices = brancheOffices;
        }
 
        @Override
index c44743ea5044834fe1832c48441a93c9d5765fe9..9ca5b8879da5458ff1ce22f6978fb872032b5db1 100644 (file)
@@ -102,7 +102,7 @@ public class CompanyBasicData implements BusinessBasicData, Comparable<BusinessB
        /**
         * Company's main phone number: +ccxxxxxxxxxx
         */
-       @JoinColumn (name = "company_phone_number")
+       @JoinColumn (name = "company_phone_number_id")
        @OneToOne (targetEntity = LandLineNumber.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
        private DialableLandLineNumber companyPhoneNumber;
 
index bc05b2bcddcfb89e216a4b03b3dd05865b185dec..cf204e37aec5f20c4c200f941b5b6e6dac1a6d54 100644 (file)
@@ -169,22 +169,36 @@ public interface BranchOffice extends Serializable {
        void setBranchId (final Long branchId);
 
        /**
-        * Getter for branch office's country code
+        * Getter for branch office's country
         * <p>
-        * @return Branch office's country code
+        * @return Branch office's country
         */
        Country getBranchCountry ();
 
        /**
-        * Setter for branch office's country code
+        * Setter for branch office's country
         * <p>
-        * @param branchCountryCode Branch office's country code
+        * @param branchCountryCode Branch office's country
         */
        void setBranchCountry (final Country branchCountryCode);
 
+       /**
+        * Getter for branch office's company
+        * <p>
+        * @return Branch office's company
+        */
+       Long getBranchCompanyContact ();
+
+       /**
+        * Setter for branch office's company
+        * <p>
+        * @param branchCompanyContact Branch office's company
+        */
+       void setBranchCompanyContact (final Long branchCompanyContact);
+
        @Override
-        boolean equals (final Object object);
+       boolean equals (final Object object);
 
        @Override
-        int hashCode ();
+       int hashCode ();
 }
index 0826881e4bf8999b082dac9ef6a49b5f9f934ae7..31a5949d43e16daf426bf57fecf52f09a466d3a7 100644 (file)
@@ -28,6 +28,7 @@ import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
+import org.mxchange.jcontactsbusiness.CompanyContact;
 import org.mxchange.jcountry.data.Country;
 import org.mxchange.jcountry.data.CountryData;
 import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
@@ -40,8 +41,8 @@ import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
  * <p>
  * @author Roland Haeder
  */
-@Entity (name = "company_branches")
-@Table (name = "company_branches")
+@Entity (name = "company_branch_offices")
+@Table (name = "company_branch_offices")
 public class CompanyBranchOffice implements BranchOffice, Comparable<BranchOffice> {
 
        /**
@@ -56,6 +57,13 @@ public class CompanyBranchOffice implements BranchOffice, Comparable<BranchOffic
        @Column (name = "branch_city", length = 100, nullable = false)
        private String branchCity;
 
+       /**
+        * Company that has this branch office
+        */
+       @JoinColumn (name = "branch_company_id", nullable = false, updatable = false)
+       @OneToOne (targetEntity = CompanyContact.class, optional = false, cascade = CascadeType.ALL)
+       private Long branchCompanyContact;
+
        /**
         * Branch office's country code
         */
@@ -173,6 +181,16 @@ public class CompanyBranchOffice implements BranchOffice, Comparable<BranchOffic
                this.branchCity = branchCity;
        }
 
+       @Override
+       public Long getBranchCompanyContact () {
+               return this.branchCompanyContact;
+       }
+
+       @Override
+       public void setBranchCompanyContact (final Long branchCompanyContact) {
+               this.branchCompanyContact = branchCompanyContact;
+       }
+
        @Override
        public Country getBranchCountry () {
                return this.branchCountry;