Rev 259 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 259 | Rev 325 | ||
|---|---|---|---|
| Line 9... | Line 9... | ||
| 9 | import javax.persistence.Id; |
9 | import javax.persistence.Id; |
| 10 | import javax.persistence.JoinColumn; |
10 | import javax.persistence.JoinColumn; |
| 11 | import javax.persistence.ManyToOne; |
11 | import javax.persistence.ManyToOne; |
| 12 | import javax.persistence.SequenceGenerator; |
12 | import javax.persistence.SequenceGenerator; |
| 13 | import javax.persistence.Table; |
13 | import javax.persistence.Table; |
| - | 14 | import javax.validation.constraints.NotNull; |
|
| 14 | 15 | ||
| 15 | import org.hibernate.annotations.ForeignKey; |
16 | import org.hibernate.annotations.ForeignKey; |
| - | 17 | ||
| - | 18 | import br.com.ec.core.interfaces.Alterar; |
|
| - | 19 | import br.com.ec.core.interfaces.Cadastrar; |
|
| 16 | 20 | ||
| 17 | @Entity |
21 | @Entity |
| 18 | @Table(name="sec_usuario_perfil", schema="sc_sec") |
22 | @Table(name="sec_usuario_perfil", schema="sc_sec") |
| 19 | public class UsuarioPerfil implements Serializable { |
23 | public class UsuarioPerfil implements Serializable { |
| 20 | 24 | ||
| 21 | private static final long serialVersionUID = 1L; |
25 | private static final long serialVersionUID = 1L; |
| 22 | 26 | ||
| 23 | private Long sequencial; |
27 | private Long sequencial; |
| 24 | private Usuario usuario; |
28 | private Usuario usuario; |
| 25 | private Perfil perfil; |
29 | private Perfil perfil; |
| - | 30 | ||
| - | 31 | public UsuarioPerfil() {} |
|
| - | 32 | ||
| - | 33 | public UsuarioPerfil(Long sequencial) { |
|
| - | 34 | this.sequencial = sequencial; |
|
| - | 35 | }
|
|
| 26 | 36 | ||
| 27 | @Id |
37 | @Id |
| 28 | @SequenceGenerator(name = "sq_usuarioperfil") |
38 | @SequenceGenerator(name = "sq_usuarioperfil") |
| 29 | @GeneratedValue(strategy=GenerationType.IDENTITY) |
39 | @GeneratedValue(strategy=GenerationType.IDENTITY) |
| 30 | @Column(name="seq_usuario_perfil", nullable=false) |
40 | @Column(name="seq_usuario_perfil", nullable=false) |
| Line 36... | Line 46... | ||
| 36 | }
|
46 | }
|
| 37 | 47 | ||
| 38 | @ManyToOne |
48 | @ManyToOne |
| 39 | @ForeignKey(name="fk_usuarioperfil_usuario") |
49 | @ForeignKey(name="fk_usuarioperfil_usuario") |
| 40 | @JoinColumn(name = "seq_usuario", nullable = false) |
50 | @JoinColumn(name = "seq_usuario", nullable = false) |
| - | 51 | @NotNull(message="Obrigatório informar o usuário", groups={Cadastrar.class, Alterar.class}) |
|
| 41 | public Usuario getUsuario() { |
52 | public Usuario getUsuario() { |
| 42 | return usuario; |
53 | return usuario; |
| 43 | }
|
54 | }
|
| 44 | public void setUsuario(Usuario usuario) { |
55 | public void setUsuario(Usuario usuario) { |
| 45 | this.usuario = usuario; |
56 | this.usuario = usuario; |
| 46 | }
|
57 | }
|
| 47 | 58 | ||
| 48 | @ManyToOne |
59 | @ManyToOne |
| 49 | @ForeignKey(name="fk_usuarioperfil_perfil") |
60 | @ForeignKey(name="fk_usuarioperfil_perfil") |
| 50 | @JoinColumn(name = "cod_perfil", nullable=false) |
61 | @JoinColumn(name = "cod_perfil", nullable=false) |
| - | 62 | @NotNull(message="Obrigatório informar o perfil", groups={Cadastrar.class, Alterar.class}) |
|
| 51 | public Perfil getPerfil() { |
63 | public Perfil getPerfil() { |
| 52 | return perfil; |
64 | return perfil; |
| 53 | }
|
65 | }
|
| 54 | public void setPerfil(Perfil perfil) { |
66 | public void setPerfil(Perfil perfil) { |
| 55 | this.perfil = perfil; |
67 | this.perfil = perfil; |