@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")
}
)
+@SuppressWarnings ("PersistenceUnitPresent")
public class LoginUser implements User {
/**
*/
private static final long serialVersionUID = 4_328_454_581_751L;
+ /**
+ * Last locked reason
+ */
+ @Lob
+ @Column (name = "user_last_locked_reason")
+ private String lastLockedReason;
+
/**
* Account status
*/
/**
* 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;
/**
* Encrypted password
*/
+ @Basic (optional = false)
@Column (name = "user_encrypted_password", nullable = false)
private String userEncryptedPassword;
@Column (name = "user_last_locked_timestamp")
private Calendar userLastLocked;
- /**
- * Last locked reason
- */
- @Lob
- @Column (name = "user_last_locked_reason")
- private String lastLockedReason;
-
/**
* User name
*/
+ @Basic (optional = false)
@Column (name = "user_name", nullable = false, length = 20)
private String userName;
- /**
- * When this user has been updated
- */
- @Temporal (TemporalType.TIMESTAMP)
- @Column (name = "user_updated")
- private Calendar userUpdated;
-
/**
* Profile mode of this user
*/
@Column (name = "user_profile_mode", nullable = false)
private ProfileMode userProfileMode;
+ /**
+ * When this user has been updated
+ */
+ @Temporal (TemporalType.TIMESTAMP)
+ @Column (name = "user_updated")
+ private Calendar userUpdated;
+
/**
* Default constructor
*/
@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());
@Override
public boolean equals (final Object object) {
- if (object == null) {
+ if (null == object) {
return false;
}
- if (getClass() != object.getClass()) {
+ if (this.getClass() != object.getClass()) {
return false;
}
(Objects.equals(this.getUserId(), other.getUserId())));
}
+ @Override
+ public int hashCode () {
+ int hash = 5;
+ hash = 83 * hash + Objects.hashCode(this.getUserName());
+ hash = 83 * hash + Objects.hashCode(this.getUserId());
+ return hash;
+ }
+
@Override
public String getLastLockedReason () {
return this.lastLockedReason;
this.userUpdated = userUpdated;
}
- @Override
- public int hashCode () {
- int hash = 5;
- hash = 83 * hash + Objects.hashCode(this.getUserName());
- hash = 83 * hash + Objects.hashCode(this.getUserId());
- return hash;
- }
}