From: Roland Häder Date: Fri, 13 May 2016 09:49:35 +0000 (+0200) Subject: Continued a bit: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f7a1ee70e8af1bff1406fda22400333233a3b6b6;p=jcontacts-core.git Continued a bit: - added named query for finding contacts by email address - addeded exception constructor for email address (could be used for names, careful, no good type-hint here) and causing exception --- diff --git a/src/org/mxchange/jcontacts/contact/UserContact.java b/src/org/mxchange/jcontacts/contact/UserContact.java index 748574a..9304cf4 100644 --- a/src/org/mxchange/jcontacts/contact/UserContact.java +++ b/src/org/mxchange/jcontacts/contact/UserContact.java @@ -70,10 +70,11 @@ import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; ) @NamedQueries ( { - @NamedQuery( name = "AllContacts", query = "SELECT c FROM contacts AS c ORDER BY c.contactId ASC"), - @NamedQuery( name = "AllContactEmailAddresses", query = "SELECT c.contactEmailAddress FROM contacts AS c ORDER BY c.contactId ASC"), + @NamedQuery (name = "AllContacts", query = "SELECT c FROM contacts AS c ORDER BY c.contactId ASC"), + @NamedQuery (name = "AllContactEmailAddresses", query = "SELECT c.contactEmailAddress FROM contacts AS c ORDER BY c.contactId ASC"), @NamedQuery (name = "AllContactsByCellphone", query = "SELECT c FROM contacts AS c WHERE c.contactCellphoneNumber = :cellPhone ORDER BY c.contactId ASC"), - @NamedQuery (name = "SearchContactById", query = "SELECT c FROM contacts AS c WHERE c.contactId = :contactId") + @NamedQuery (name = "SearchContactById", query = "SELECT c FROM contacts AS c WHERE c.contactId = :contactId"), + @NamedQuery(name = "SearchContactByEmailAddress", query = "SELECT c FROM contacts AS c WHERE c.contactEmailAddress = :emailAddress") } ) @SuppressWarnings ("PersistenceUnitPresent") @@ -232,8 +233,8 @@ public class UserContact implements Contact { /** * Constructor for contactGender and names *

- * @param contactGender Gender instance - * @param contactFirstName First name + * @param contactGender Gender instance + * @param contactFirstName First name * @param contactFamilyName Family name */ public UserContact (final Gender contactGender, final String contactFirstName, final String contactFamilyName) { diff --git a/src/org/mxchange/jcontacts/exceptions/ContactNotFoundException.java b/src/org/mxchange/jcontacts/exceptions/ContactNotFoundException.java index eb2d00d..1a50198 100644 --- a/src/org/mxchange/jcontacts/exceptions/ContactNotFoundException.java +++ b/src/org/mxchange/jcontacts/exceptions/ContactNotFoundException.java @@ -44,11 +44,22 @@ public class ContactNotFoundException extends Exception { * Constructor with contact id and causing exception *

* @param contactId Contact id - * @param cause Causing exception + * @param cause Causing exception */ public ContactNotFoundException (final Long contactId, final Throwable cause) { // Call super constructor with message and cause super(MessageFormat.format("Contact with id {0} was not found.", contactId), cause); //NOI18N } + /** + * Constructor with email address and causing exception + *

+ * @param emailAddress Email address + * @param cause Causing exception + */ + public ContactNotFoundException (final String emailAddress, final Throwable cause) { + // Call super constructor with message and cause + super(MessageFormat.format("Contact with email address {0} was not found.", emailAddress), cause); //NOI18N + } + }