1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
package com.wangi.aeropro.entites;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;
@Entity(name="users")
public class User implements Serializable {
@Id
@NotNull
@Size(min=3,max=15)
private String name;
@NotNull
@Size(min = 4)
private String password;
private boolean actived;
@ManyToMany
@JoinTable(name = "USERS_ROLES")
private Collection<Role> roles;
public User() {
super();
// TODO Auto-generated constructor stub
}
public User(String name, String password, boolean actived) {
super();
this.name = name;
this.password = password;
this.actived = actived;
}
public User(String name) {
super();
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public boolean isActived() {
return actived;
}
public void setActived(boolean actived) {
this.actived = actived;
}
public Collection<Role> getRoles() {
return roles;
}
public void setRoles(Collection<Role> roles) {
this.roles = roles;
}
}
package com.wangi.aeropro.entites;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;
@Entity
public class Role implements Serializable{
@Id
@NotNull
@Size(min=3,max=15)
private String name;
@NotNull
@Size(min=5,max=30)
private String desciption;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Role(String name, String desciption) {
super();
this.name = name;
this.desciption = desciption;
}
public Role() {
}
public Role(String name) {
this.name = name;
}
public String getDesciption() {
return desciption;
}
public void setDesciption(String desciption) {
this.desciption = desciption;
}
} |
Partager