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

package hibernate;

import java.io.Serializable;
import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author Ani
 */
@Entity
@Table(name="userdata")
public class Userdata implements Serializable{
    @Id
    @Column(name="username", length=50, nullable=false, unique=false)
    private String username;
    @Column(name="email", length=100, nullable=false)
    private String email;
    @Column(name="dateOfReg")
    private Date dateOFReg;
    @Column(name="id", nullable=false)
    private Integer id;
    @Column(name="tablename", nullable=false, length=100)
    private String tablename;
    @OneToOne(mappedBy="userdata")
    @JoinColumn(name="username")
    private Userstatistic userstatistic;
    @OneToOne(mappedBy="userdata")
    @JoinColumn(name="username")
    private Passwordstore password;

    
    public Userdata() {

    }

    public Userdata(String username, String password, String email, Integer id, Date dateOFReg, String tablename) {
        this.username = username;
        this.email = email;
        this.dateOFReg = dateOFReg;
        this.id = id;
        this.tablename = tablename;
        this.password = new Passwordstore(this, password);
        this.userstatistic = new Userstatistic(this, 0, 0, 0, 0);
    }


    public Integer getId() {
        return id;
    }

    public void setID(Integer id) {
        this.id = id;
    }

    public Date getDateOFReg() {
        return dateOFReg;
    }

    public void setDateOFReg(Date dateOFReg) {
        this.dateOFReg = dateOFReg;
    }

    public String getEmail() {
        return email;
    }

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

    public Passwordstore getPassword() {
        return password;
    }

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

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Userstatistic getUserstatistic() {
        return userstatistic;
    }

    public void setUserstatistic(Userstatistic userstatistic) {
        this.userstatistic = userstatistic;
    }

    public String getTablename() {
        return tablename;
    }

    public void setTablename(String tablename) {
        this.tablename = tablename;
    }


}
