/*
- * 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
/**
* A POJO for address book entries
* <p>
- * @author Roland Haeder
+ * @author Roland Haeder<roland@mxchange.org>
*/
@Entity (name = "addressbook_entries")
@Table (name = "addressbook_entries")
name = "SearchUsersAddressbookEntries",
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
* Connection to table "business_contacts" (commercial contacts)
*/
@JoinColumn (name = "entry_business_contact_id", updatable = false)
- @OneToOne (targetEntity = CompanyContact.class, cascade = CascadeType.MERGE)
+ @OneToOne (targetEntity = CompanyContact.class, cascade = CascadeType.REFRESH)
private BusinessContact addressbookEntryBusinessContact;
/**
* Connection to table "contacts" (private contacts)
*/
@JoinColumn (name = "entry_private_contact_id", updatable = false)
- @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.MERGE)
+ @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.MERGE)
+ @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;
}
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;
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;
- }
-
}