]> git.mxchange.org Git - juser-login-core.git/blobdiff - src/org/mxchange/jusercore/model/user/LoginUser.java
ignored create-persistence-unit warning as no persistence.xml shall be created here...
[juser-login-core.git] / src / org / mxchange / jusercore / model / user / LoginUser.java
index d01c952071b316457710d4efbcec1ea0524ed375..33678e58aa60c177238ad1e8ca4c35da2633cbfc 100644 (file)
@@ -70,11 +70,13 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus;
                        @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)"),
                        @NamedQuery (name = "SearchAllUsersExcept", query = "SELECT u FROM users AS u WHERE u != :user ORDER BY u.userId ASC"),
+                       @NamedQuery (name = "AllUsers", query = "SELECT u FROM users AS u ORDER BY u.userId ASC"),
                        @NamedQuery (name = "AllPublicUsers", query = "SELECT u FROM users AS u WHERE u.userAccountStatus = :status AND u.userProfileMode = :mode ORDER BY u.userId ASC"),
                        @NamedQuery (name = "AllMemberPublicUsers", query = "SELECT u FROM users AS u WHERE u.userAccountStatus = :status AND u.userProfileMode IN (:public, :members) ORDER BY u.userId ASC")
                }
 )
-public class LoginUser implements User, Comparable<User> {
+@SuppressWarnings ("PersistenceUnitPresent")
+public class LoginUser implements User {
 
        /**
         * Serial number
@@ -105,7 +107,7 @@ public class LoginUser implements User, Comparable<User> {
        /**
         * Id number from "contacts" table
         */
-       @JoinColumn (name = "user_contact_id", nullable = false, updatable = false)
+       @JoinColumn (name = "user_contact_id", referencedColumnName = "contact_id", nullable = false, updatable = false, unique = true)
        @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false)
        private Contact userContact;
 
@@ -169,15 +171,13 @@ public class LoginUser implements User, Comparable<User> {
                this.userProfileMode = ProfileMode.INVISIBLE;
        }
 
-       @Override
-       public int compareTo (final User user) {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-       }
-
        @Override
        public void copyAll (final User user) {
-               // Copy also contact data
-               this.getUserContact().copyAll(user.getUserContact());
+               // Is contact set?
+               if (user.getUserContact() instanceof Contact) {
+                       // Copy also contact data
+                       this.getUserContact().copyAll(user.getUserContact());
+               }
 
                // Copy other data
                this.setUserConfirmKey(user.getUserConfirmKey());
@@ -190,7 +190,7 @@ public class LoginUser implements User, Comparable<User> {
 
        @Override
        public boolean equals (final Object object) {
-               if (object == null) {
+               if (null == object) {
                        return false;
                }
                if (this.getClass() != object.getClass()) {