package org.fuc.entities;

//import org.codehaus.jackson.annotate.JsonIgnore;

import javax.persistence.*;

@SuppressWarnings("serial")
@Entity
@Table(name = "account")
@NamedQueries({@NamedQuery(name = Account.FIND_BY_LOGIN, query = "select a from Account a where a.login = :login"),
    @NamedQuery(name = Account.FIND_BY_ROLE, query = "select a from Account a where a.role = :role"),
    @NamedQuery(name = Account.FIND_BY_ID, query = "select a from Account a where a.id = :id"),
    @NamedQuery(name = Account.FIND_ALL, query = "select a from Account a")}
)
public class Account implements java.io.Serializable {
    public static final String FIND_BY_LOGIN = "Account.findByLogin";
    public static final String FIND_BY_ROLE = "Account.findByRole";
    public static final String FIND_BY_ID = "Account.findById";
    public static final String FIND_ALL = "Account.findAll";

    private Long id;

    private String login;

    private String password;

    private String role = "undefined";

    protected Account() {
    }

    public Account(Long id, String login, String password, String role) {
        this.id = id;
        this.login = login;
        this.password = password;
        this.role = role;
    }

    public Account(String login, String password, String role) {
        this.login = login;
        this.password = password;
        this.role = role;
    }

    @Id
    @SequenceGenerator(name = "user_id_seq", sequenceName = "user_id_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_id_seq")
    public Long getId() {
        return id;
    }

    @Column(unique = true)
    public String getLogin() {
        return login;
    }

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

//    @JsonIgnore
    public String getPassword() {
        return password;
    }

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

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public void setId(Long id) {
        this.id = id;
    }
}
