Package cm.dpassyann.speedDating.model.user.bean

Source Code of cm.dpassyann.speedDating.model.user.bean.User

/**
*
*/
package cm.dpassyann.speedDating.model.user.bean;

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

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
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;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import cm.dpassyann.speedDating.model.adress.bean.Address;
import cm.dpassyann.speedDating.model.user.UserConstant;

/**
* Pour le projet : AmourMeZam
* @author deungoueyann
* @description cette classe permet de stocker les information relative à un utilisateur
* @date fait le : 19 nov. 2012
*/


@NamedQueries({
  @NamedQuery(name = UserConstant.USER_GET_ALL_QUERY, query = "FROM User"),
  @NamedQuery(name = UserConstant.USER_CONNECTION_QUERY,query = "FROM User u WHERE u.parameter.username =:username AND u.parameter.password =:password")
})
@Entity
@Table(name="user", uniqueConstraints = {
    @UniqueConstraint(columnNames = "EMAIL") }
)
public class User implements Serializable{
 
  /**
   *
   */
  private static final long serialVersionUID = -5092950603900013069L;

  @Id
  @Column(name="USER_ID")
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  private Long id;
 
  @Column(name="EMAIL", nullable=false)
  private String email;
 
  @Column(name="BIRTHDAY", nullable=false)
  @Temporal(TemporalType.DATE)
  private Date birthday;
 
  @Column(name="STATE", nullable=false, columnDefinition="tinyint default false")
  private boolean actived;
 
  @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="ADDRESS_ID", nullable=false, referencedColumnName="ADDRESS_ID")
    private Address address;
 
  @OneToOne(cascade=CascadeType.ALL)
    @JoinColumn(name="CONNEXION_ID", nullable=false, referencedColumnName="CONNEXION_ID")
    private ConnectionParameter parameter;
 
  public User(Long id, ConnectionParameter parameter, String username, String password, Address address, String email, Date birthday) {
    this.id = id;
    this.address = address;
    this.email = email;
    this.birthday = birthday;
    this.parameter = parameter;
  }
 
  public  User(){
    this.id = new Long(-1);
    this.address = new Address();
    this.email = "";
    this.birthday = new Date();
    this.parameter = new ConnectionParameter();
  }
 
  /**
   * @return la id
   */
  public Long getId() {
    return id;
  }

  /**
   * @param id la id à initialiser
   */
  public void setId(Long id) {
    this.id = id;
  }

  /**
   * @return la email
   */
  public String getEmail() {
    return email;
  }

  /**
   * @param email la email à initialiser
   */
  public void setEmail(String email) {
    this.email = email;
  }

  /**
   * @return la birthday
   */
  public Date getBirthday() {
    return birthday;
  }

  /**
   * @param birthday la birthday à initialiser
   */
  public void setBirthday(Date birthday) {
    this.birthday = birthday;
  }

  /**
   * @return la address
   */
  public Address getAddress() {
    return address;
  }

  /**
   * @param address la address à initialiser
   */
  public void setAddress(Address address) {
    this.address = address;
  }

  /**
   * @return la actived
   */
  public boolean isActived() {
    return actived;
  }

  /**
   * @param actived la actived à initialiser
   */
  public void setActived(boolean actived) {
    this.actived = actived;
  }

  /**
   * @return la parameter
   */
  public ConnectionParameter getParameter() {
    return parameter;
  }

  /**
   * @param parameter la parameter à initialiser
   */
  public void setParameter(ConnectionParameter parameter) {
    this.parameter = parameter;
  }

  /* (non-Javadoc)
   * @see java.lang.Object#toString()
   */
  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append("User [\nid  --> ");
    builder.append(id);
    builder.append("\nemail  --> ");
    builder.append(email);
    builder.append("\nbirthday  --> ");
    builder.append(birthday);
    builder.append("\nactived  --> ");
    builder.append(actived);
    builder.append("\naddress  --> ");
    builder.append(address);
    builder.append("\nparameter  --> ");
    builder.append(parameter);
    builder.append("\n]");
    return builder.toString();
  }
}
TOP

Related Classes of cm.dpassyann.speedDating.model.user.bean.User

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.