User.java 10.7 KB
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fi.insomnia.bortal.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * 
 * @author jkj
 */
@Entity
@Table(name = "users")
@NamedQueries( {
	@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
	@NamedQuery(name = "User.findByUsersId", query = "SELECT u FROM User u WHERE u.usersId = :usersId"),
	@NamedQuery(name = "User.findByCreated", query = "SELECT u FROM User u WHERE u.created = :created"),
	@NamedQuery(name = "User.findByActive", query = "SELECT u FROM User u WHERE u.active = :active"),
	@NamedQuery(name = "User.findByPassword", query = "SELECT u FROM User u WHERE u.password = :password"),
	@NamedQuery(name = "User.findByLastname", query = "SELECT u FROM User u WHERE u.lastname = :lastname"),
	@NamedQuery(name = "User.findByFirstnames", query = "SELECT u FROM User u WHERE u.firstnames = :firstnames"),
	@NamedQuery(name = "User.findByBirthday", query = "SELECT u FROM User u WHERE u.birthday = :birthday"),
	@NamedQuery(name = "User.findByNick", query = "SELECT u FROM User u WHERE u.nick = :nick"),
	@NamedQuery(name = "User.findByEmail", query = "SELECT u FROM User u WHERE u.email = :email"),
	@NamedQuery(name = "User.findByAddress", query = "SELECT u FROM User u WHERE u.address = :address"),
	@NamedQuery(name = "User.findByZip", query = "SELECT u FROM User u WHERE u.zip = :zip"),
	@NamedQuery(name = "User.findByPostalCode", query = "SELECT u FROM User u WHERE u.postalCode = :postalCode"),
	@NamedQuery(name = "User.findByTown", query = "SELECT u FROM User u WHERE u.town = :town"),
	@NamedQuery(name = "User.findByPhone", query = "SELECT u FROM User u WHERE u.phone = :phone"),
	@NamedQuery(name = "User.findByFemale", query = "SELECT u FROM User u WHERE u.female = :female"),
	@NamedQuery(name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") })
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "users_id", nullable = false)
    private Integer usersId;
    @Column(name = "created", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date created;
    @Column(name = "active", nullable = false)
    private boolean active;
    @Column(name = "password", length = 2147483647)
    private String password;
    @Column(name = "lastname", nullable = false, length = 2147483647)
    private String lastname;
    @Column(name = "firstnames", nullable = false, length = 2147483647)
    private String firstnames;
    @Column(name = "birthday")
    @Temporal(TemporalType.TIMESTAMP)
    private Date birthday;
    @Column(name = "nick", length = 2147483647)
    private String nick;
    @Column(name = "email", length = 2147483647)
    private String email;
    @Column(name = "address", length = 2147483647)
    private String address;
    @Column(name = "zip", length = 2147483647)
    private String zip;
    @Column(name = "postal_code", length = 2147483647)
    private String postalCode;
    @Column(name = "town", length = 2147483647)
    private String town;
    @Column(name = "phone", length = 2147483647)
    private String phone;
    @Column(name = "female")
    private Boolean female;
    @Lob
    @Column(name = "gender")
    private Object gender;
    @Column(name = "login", length = 2147483647)
    private String login;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usersId")
    private List<Vote> voteList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usersId")
    private List<RoleMembership> roleMembershipList;
    @OneToMany(mappedBy = "usersId")
    private List<LogEntry> logEntryList;
    @OneToMany(mappedBy = "usersId")
    private List<UserImage> userImageList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usersId")
    private List<CompoEntryParticipant> compoEntryParticipantList;
    @OneToMany(mappedBy = "creator")
    private List<CompoEntry> compoEntryList;
    @OneToMany(mappedBy = "groupCreator")
    private List<PlaceGroup> placeGroupList;
    @OneToMany(mappedBy = "usersId")
    private List<GroupMembership> groupMembershipList;
    @OneToMany(mappedBy = "usersId")
    private List<Place> placeList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usersId")
    private List<PrintedCard> printedCardList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usersId")
    private List<AccountEvent> accountEventList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usersId")
    private List<DiscountInstance> discountInstanceList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usersId")
    private List<Bill> billList;

    public User() {
    }

    public User(Integer usersId) {
	this.usersId = usersId;
    }

    public User(Integer usersId, Date created, boolean active, String lastname,
	    String firstnames) {
	this.usersId = usersId;
	this.created = created;
	this.active = active;
	this.lastname = lastname;
	this.firstnames = firstnames;
    }

    public Integer getUsersId() {
	return usersId;
    }

    public void setUsersId(Integer usersId) {
	this.usersId = usersId;
    }

    public Date getCreated() {
	return created;
    }

    public void setCreated(Date created) {
	this.created = created;
    }

    public boolean getActive() {
	return active;
    }

    public void setActive(boolean active) {
	this.active = active;
    }

    public String getPassword() {
	return password;
    }

    public void setPassword(String password) {
	this.password = password;
    }

    public String getLastname() {
	return lastname;
    }

    public void setLastname(String lastname) {
	this.lastname = lastname;
    }

    public String getFirstnames() {
	return firstnames;
    }

    public void setFirstnames(String firstnames) {
	this.firstnames = firstnames;
    }

    public Date getBirthday() {
	return birthday;
    }

    public void setBirthday(Date birthday) {
	this.birthday = birthday;
    }

    public String getNick() {
	return nick;
    }

    public void setNick(String nick) {
	this.nick = nick;
    }

    public String getEmail() {
	return email;
    }

    public void setEmail(String email) {
	this.email = email;
    }

    public String getAddress() {
	return address;
    }

    public void setAddress(String address) {
	this.address = address;
    }

    public String getZip() {
	return zip;
    }

    public void setZip(String zip) {
	this.zip = zip;
    }

    public String getPostalCode() {
	return postalCode;
    }

    public void setPostalCode(String postalCode) {
	this.postalCode = postalCode;
    }

    public String getTown() {
	return town;
    }

    public void setTown(String town) {
	this.town = town;
    }

    public String getPhone() {
	return phone;
    }

    public void setPhone(String phone) {
	this.phone = phone;
    }

    public Boolean getFemale() {
	return female;
    }

    public void setFemale(Boolean female) {
	this.female = female;
    }

    public Object getGender() {
	return gender;
    }

    public void setGender(Object gender) {
	this.gender = gender;
    }

    public String getLogin() {
	return login;
    }

    public void setLogin(String login) {
	this.login = login;
    }

    public List<Vote> getVoteList() {
	return voteList;
    }

    public void setVoteList(List<Vote> voteList) {
	this.voteList = voteList;
    }

    public List<RoleMembership> getRoleMembershipList() {
	return roleMembershipList;
    }

    public void setRoleMembershipList(List<RoleMembership> roleMembershipList) {
	this.roleMembershipList = roleMembershipList;
    }

    public List<LogEntry> getLogEntryList() {
	return logEntryList;
    }

    public void setLogEntryList(List<LogEntry> logEntryList) {
	this.logEntryList = logEntryList;
    }

    public List<UserImage> getUserImageList() {
	return userImageList;
    }

    public void setUserImageList(List<UserImage> userImageList) {
	this.userImageList = userImageList;
    }

    public List<CompoEntryParticipant> getCompoEntryParticipantList() {
	return compoEntryParticipantList;
    }

    public void setCompoEntryParticipantList(
	    List<CompoEntryParticipant> compoEntryParticipantList) {
	this.compoEntryParticipantList = compoEntryParticipantList;
    }

    public List<CompoEntry> getCompoEntryList() {
	return compoEntryList;
    }

    public void setCompoEntryList(List<CompoEntry> compoEntryList) {
	this.compoEntryList = compoEntryList;
    }

    public List<PlaceGroup> getPlaceGroupList() {
	return placeGroupList;
    }

    public void setPlaceGroupList(List<PlaceGroup> placeGroupList) {
	this.placeGroupList = placeGroupList;
    }

    public List<GroupMembership> getGroupMembershipList() {
	return groupMembershipList;
    }

    public void setGroupMembershipList(List<GroupMembership> groupMembershipList) {
	this.groupMembershipList = groupMembershipList;
    }

    public List<Place> getPlaceList() {
	return placeList;
    }

    public void setPlaceList(List<Place> placeList) {
	this.placeList = placeList;
    }

    public List<PrintedCard> getPrintedCardList() {
	return printedCardList;
    }

    public void setPrintedCardList(List<PrintedCard> printedCardList) {
	this.printedCardList = printedCardList;
    }

    public List<AccountEvent> getAccountEventList() {
	return accountEventList;
    }

    public void setAccountEventList(List<AccountEvent> accountEventList) {
	this.accountEventList = accountEventList;
    }

    public List<DiscountInstance> getDiscountInstanceList() {
	return discountInstanceList;
    }

    public void setDiscountInstanceList(
	    List<DiscountInstance> discountInstanceList) {
	this.discountInstanceList = discountInstanceList;
    }

    public List<Bill> getBillList() {
	return billList;
    }

    public void setBillList(List<Bill> billList) {
	this.billList = billList;
    }

    @Override
    public int hashCode() {
	int hash = 0;
	hash += (usersId != null ? usersId.hashCode() : 0);
	return hash;
    }

    @Override
    public boolean equals(Object object) {
	// TODO: Warning - this method won't work in the case the id fields are
	// not set
	if (!(object instanceof User)) {
	    return false;
	}
	User other = (User) object;
	if ((this.usersId == null && other.usersId != null)
		|| (this.usersId != null && !this.usersId.equals(other.usersId))) {
	    return false;
	}
	return true;
    }

    @Override
    public String toString() {
	return "fi.insomnia.bortal.model.User[usersId=" + usersId + "]";
    }

}