]> git.mxchange.org Git - juser-login-core.git/commitdiff
Continued a bit:
authorRoland Haeder <roland@mxchange.org>
Sat, 12 Mar 2016 17:11:51 +0000 (18:11 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 12 Mar 2016 17:11:51 +0000 (18:11 +0100)
- added named query for email-change lookup
- added named query for directly looking for user instance (untested!)

src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java
src/org/mxchange/jusercore/model/user/LoginUser.java

index 0fa4ec271f2414884dfd95e6221b00b825bf9fb9..e3c4225cda1f19b6ae4abdc76f6dce0910e6ee5b 100644 (file)
@@ -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
+        * <p>
+        * @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) {
index c974976a111f291418e5b929283dc543ded76f14..3264b5b9171f0307f2acf04d3ab0254078571e83 100644 (file)
@@ -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)"),