From: Roland Haeder Date: Sat, 12 Mar 2016 17:11:51 +0000 (+0100) Subject: Continued a bit: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=753c5faee030ae6419a34939098ad6cbe273fb1a;p=juser-core.git Continued a bit: - added named query for email-change lookup - added named query for directly looking for user instance (untested!) --- diff --git a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java index 0fa4ec2..e3c4225 100644 --- a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java +++ b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java @@ -28,6 +28,8 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; @@ -43,6 +45,9 @@ import org.mxchange.jusercore.model.user.User; */ @Entity (name = "email_changes") @Table (name = "email_changes") +@NamedQueries ( + @NamedQuery (name = "SearchEmailChangeByEmail", query = "SELECT e FROM email_changes AS e WHERE LOWER(e.emailAddress) LIKE LOWER(:email)") +) public class EmailAddressChange implements ChangeableEmailAddress { /** @@ -104,6 +109,23 @@ public class EmailAddressChange implements ChangeableEmailAddress { this.emailChangeStatus = EmailChangeStatus.NEW; } + /** + * Constructor with user, email address and creation timestamp to set + *

+ * @param user User instance + * @param emailAddress Email address to queue + * @param emailChangeCreated Timestamp for creation + */ + public EmailAddressChange (final User user, final String emailAddress, final Calendar emailChangeCreated) { + // Call super constructor + this(); + + // Set all + this.emailAddress = emailAddress; + this.emailChangeUser = user; + this.emailChangeCreated = emailChangeCreated; + } + @Override public boolean equals (final Object object) { if (this == object) { diff --git a/src/org/mxchange/jusercore/model/user/LoginUser.java b/src/org/mxchange/jusercore/model/user/LoginUser.java index c974976..3264b5b 100644 --- a/src/org/mxchange/jusercore/model/user/LoginUser.java +++ b/src/org/mxchange/jusercore/model/user/LoginUser.java @@ -66,6 +66,7 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus; { @NamedQuery (name = "AllUserNames", query = "SELECT DISTINCT u.userName FROM users AS u ORDER BY u.userId ASC"), @NamedQuery (name = "AllEmailAddresses", query = "SELECT DISTINCT c.contactEmailAddress FROM contacts AS c INNER JOIN users AS u ON u.userContact = c ORDER BY c.contactId ASC"), + @NamedQuery (name = "SearchUser", query = "SELECT u FROM users AS u WHERE u = :param"), @NamedQuery (name = "SearchUserName", query = "SELECT u FROM users AS u WHERE LOWER(u.userName) LIKE LOWER(:param)"), @NamedQuery (name = "SearchUserId", query = "SELECT u FROM users AS u WHERE u.userId = :id"), @NamedQuery (name = "SearchEmailAddress", query = "SELECT u FROM users AS u INNER JOIN contacts AS c ON u.userContact = c WHERE LOWER(c.contactEmailAddress) LIKE LOWER(:param)"),