]> git.mxchange.org Git - jfinancials-lib.git/blobdiff - src/org/mxchange/addressbook/model/addressbook/entry/UserAddressbookEntry.java
Fixed getter calls, the new ones are more descriptive.
[jfinancials-lib.git] / src / org / mxchange / addressbook / model / addressbook / entry / UserAddressbookEntry.java
index c858c276bce610b7e034e85270c7efe7dbb3a8a7..8af65ce2213502c97b7e3774613fc15cc6094ac2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Roland Haeder
+ * Copyright (C) 2016 Roland Haeder
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -42,16 +42,16 @@ import org.mxchange.jcontactsbusiness.CompanyContact;
 /**
  * A POJO for address book entries
  * <p>
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
  */
 @Entity (name = "addressbook_entries")
 @Table (name = "addressbook_entries")
 @NamedQueries (
                @NamedQuery (
                                name = "SearchUsersAddressbookEntries",
-                               query = "SELECT e FROM addressbook_entries AS e INNER JOIN addressbooks AS a ON e.addressbookId = a.addressbookId WHERE e.addressbookId = :addressbook AND a.addressbookUser = :owner ORDER BY e.addressbookEntryId ASC")
+                               query = "SELECT e FROM addressbook_entries AS e INNER JOIN addressbooks AS a ON e.addressbookId = a WHERE e.addressbookId = :addressbook AND a.addressbookUser = :owner ORDER BY e.addressbookEntryId ASC")
 )
-public class UserAddressbookEntry implements AddressbookEntry, Comparable<AddressbookEntry> {
+public class UserAddressbookEntry implements AddressbookEntry {
 
        /**
         * Serial number
@@ -62,7 +62,7 @@ public class UserAddressbookEntry implements AddressbookEntry, Comparable<Addres
         * Connection to table "business_contacts" (commercial contacts)
         */
        @JoinColumn (name = "entry_business_contact_id", updatable = false)
-       @OneToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL)
+       @OneToOne (targetEntity = CompanyContact.class, cascade = CascadeType.REFRESH)
        private BusinessContact addressbookEntryBusinessContact;
 
        /**
@@ -85,26 +85,21 @@ public class UserAddressbookEntry implements AddressbookEntry, Comparable<Addres
         * Connection to table "contacts" (private contacts)
         */
        @JoinColumn (name = "entry_private_contact_id", updatable = false)
-       @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL)
+       @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.REFRESH)
        private Contact addressbookEntryPrivateContact;
 
        /**
         * Connection to table "addressbooks"
         */
        @JoinColumn (name = "entry_addressbook_id", nullable = false, updatable = false)
-       @OneToOne (targetEntity = UserAddressbook.class, optional = false, cascade = CascadeType.ALL)
+       @OneToOne (targetEntity = UserAddressbook.class, cascade = CascadeType.REFRESH, optional = false)
        private Addressbook addressbookId;
 
-       @Override
-       public int compareTo (final AddressbookEntry addressbookEntry) {
-               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) {
+               if (null == object) {
                        return false;
-               } else if (getClass() != object.getClass()) {
+               } else if (this.getClass() != object.getClass()) {
                        return false;
                }
 
@@ -121,6 +116,15 @@ public class UserAddressbookEntry implements AddressbookEntry, Comparable<Addres
                return true;
        }
 
+       @Override
+       public int hashCode () {
+               int hash = 3;
+               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryBusinessContact());
+               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryPrivateContact());
+               hash = 19 * hash + Objects.hashCode(this.getAddressbookId());
+               return hash;
+       }
+
        @Override
        public BusinessContact getAddressbookEntryBusinessContact () {
                return this.addressbookEntryBusinessContact;
@@ -171,13 +175,4 @@ public class UserAddressbookEntry implements AddressbookEntry, Comparable<Addres
                this.addressbookId = addressbookId;
        }
 
-       @Override
-       public int hashCode () {
-               int hash = 3;
-               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryBusinessContact());
-               hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryPrivateContact());
-               hash = 19 * hash + Objects.hashCode(this.getAddressbookId());
-               return hash;
-       }
-
 }