package org.fabriquita.nucleus.models;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "user0")
public class User extends Mappable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String firstName;
    private String lastName;
    private String userName;
    private String password;
    private String email;

    private Boolean active;

    private Date lastLogin;

    @ManyToOne
    @JoinColumn(name = "group_id", nullable = true)
    private Group group;

    @ManyToOne
    @JoinColumn(name = "role_id", nullable = true)
    private Role role;

    public User() {
        active = true;
    }

    public Role getRole() {
        return role;
    }

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

    public Long getId() {
        return id;
    }

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

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public Group getGroup() {
        return group;
    }

    public void setGroup(Group group) {
        this.group = group;
    }

    public String getPassword() {
        return password;
    }

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

    public String getEmail() {
        return email;
    }

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

    public Boolean getActive() {
        return active;
    }

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

    @Override
    public String[] mappableFields() {
        return super.mappableFields();
    }

    @Override
    public Object mappableId() {
        return this.id;
    }

    public Date getLastLogin() {
        return lastLogin;
    }

    public void setLastLogin() {
        this.lastLogin = new Date();
    }

}

@@ -57,16 +57,49 @@
 .Date;%0A%0A
+import javax.persistence.Column;%0A
 import j
@@ -499,120 +499,274 @@
     
-private String firstName;%0A    private String lastName;%0A    private String userName;%0A    private String password;
+@Column(nullable = false)%0A    private String firstName;%0A%0A    @Column(nullable = false)%0A    private String lastName;%0A%0A    @Column(nullable = false)%0A    private String userName;%0A%0A    @Column(nullable = false)%0A    private String password;%0A%0A    @Column(nullable = false)
 %0A   
@@ -789,16 +789,46 @@
 email;%0A%0A
+    @Column(nullable = false)%0A
     priv
@@ -930,35 +930,36 @@
 id%22, nullable = 
-tru
+fals
 e)%0A    private G
@@ -1031,19 +1031,20 @@
 lable = 
-tru
+fals
 e)%0A    p

Add restrictions to DB user