]> git.mxchange.org Git - jcontacts-business-core.git/blobdiff - src/org/mxchange/jcontactsbusiness/CompanyContact.java
let's make sure that serial numbers of objects are never persisted (being ignored...
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / CompanyContact.java
index 35f89668a80129854a5393c9707c15e82c4ed5b8..99012d4b45373e5b9f4e165e5c3380b53c1d34c1 100644 (file)
@@ -27,7 +27,6 @@ import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
-import javax.persistence.OneToMany;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 import javax.persistence.Temporal;
@@ -46,16 +45,18 @@ import org.mxchange.jusercore.model.user.User;
 /**
  * A POJO for business contacts
  * <p>
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 @Entity (name = "company_contacts")
 @Table (name = "company_contacts")
-public class CompanyContact implements BusinessContact, Comparable<BusinessContact> {
+@SuppressWarnings ("PersistenceUnitPresent")
+public class CompanyContact implements BusinessContact {
 
        /**
         * Serial number
         */
-       private static final long serialVersionUID = 478_378_178_748_691L;
+       @Transient
+       private static final long serialVersionUID = 470_375_172_748_691L;
 
        /**
         * Reference to basic data
@@ -81,7 +82,7 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
         * Id number
         */
        @Id
-       @Column (name = "company_id", length = 20, nullable = false, updatable = false)
+       @Column (name = "company_id", nullable = false, updatable = false)
        @GeneratedValue (strategy = GenerationType.IDENTITY)
        private Long companyContactId;
 
@@ -93,33 +94,39 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
        private Employee companyFounder;
 
        /**
-        * Reference to employee list
-        */
-       @JoinColumn (name = "company_employees_id", nullable = false, updatable = false)
-       @OneToMany (targetEntity = CompanyEmployee.class, cascade = CascadeType.ALL)
-       private List<Employee> employees;
-
-       /**
-        * Reference to headquarters data
+        * Timestamp when this entry has been created
         */
-       @JoinColumn (name = "company_headquarters_data_id", nullable = false, updatable = false)
-       @OneToOne (targetEntity = CompanyHeadQuartersData.class, cascade = CascadeType.ALL, optional = false)
-       private HeadQuartersData headQuartersData;
+       @Basic (optional = false)
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "company_entry_created", nullable = false, updatable = false)
+       private Calendar contactCreated;
 
        /**
         * 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;
 
        /**
-        * Timestamp when this entry has been created
+        * Reference to headquarters data
         */
-       @Basic (optional = false)
-       @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "company_entry_created", nullable = false, updatable = false)
-       private Calendar contactCreated;
+       @JoinColumn (name = "company_headquarters_data_id", nullable = false, updatable = false)
+       @OneToOne (targetEntity = CompanyHeadQuartersData.class, cascade = CascadeType.ALL, optional = false)
+       private HeadQuartersData headQuartersData;
+
+       @Override
+       public boolean equals (final Object object) {
+               if (null == object) {
+                       return false;
+               } else if (this.getClass() != object.getClass()) {
+                       return false;
+               }
+
+               final BusinessContact other = (BusinessContact) object;
+
+               return Objects.equals(this.getBasicBusinessData(), other.getBasicBusinessData());
+       }
 
        @Override
        public BusinessBasicData getBasicBusinessData () {
@@ -132,11 +139,13 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
        }
 
        @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
        public List<BranchOffice> getBrancheOffices () {
                return this.brancheOffices;
        }
 
        @Override
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
        public void setBrancheOffices (final List<BranchOffice> brancheOffices) {
                this.brancheOffices = brancheOffices;
        }
@@ -172,11 +181,13 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
        }
 
        @Override
+       @SuppressWarnings ("ReturnOfDateField")
        public Calendar getContactCreated () {
                return this.contactCreated;
        }
 
        @Override
+       @SuppressWarnings ("AssignmentToDateFieldFromParameter")
        public void setContactCreated (final Calendar contactCreated) {
                this.contactCreated = contactCreated;
        }
@@ -191,16 +202,6 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
                this.contactUserOwner = contactUserOwner;
        }
 
-       @Override
-       public List<Employee> getEmployees () {
-               return this.employees;
-       }
-
-       @Override
-       public void setEmployees (final List<Employee> employees) {
-               this.employees = employees;
-       }
-
        @Override
        public HeadQuartersData getHeadQuartersData () {
                return this.headQuartersData;
@@ -211,24 +212,6 @@ public class CompanyContact implements BusinessContact, Comparable<BusinessConta
                this.headQuartersData = headQuartersData;
        }
 
-       @Override
-       public int compareTo (final BusinessContact businessContact) {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-       }
-
-       @Override
-       public boolean equals (final Object object) {
-               if (object == null) {
-                       return false;
-               } else if (getClass() != object.getClass()) {
-                       return false;
-               }
-
-               final BusinessContact other = (BusinessContact) object;
-
-               return Objects.equals(this.getBasicBusinessData(), other.getBasicBusinessData());
-       }
-
        @Override
        public int hashCode () {
                int hash = 3;