Rev 259 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 259 | Rev 325 | ||
|---|---|---|---|
| Line 6... | Line 6... | ||
| 6 | import javax.persistence.Entity; |
6 | import javax.persistence.Entity; |
| 7 | import javax.persistence.JoinColumn; |
7 | import javax.persistence.JoinColumn; |
| 8 | import javax.persistence.ManyToOne; |
8 | import javax.persistence.ManyToOne; |
| 9 | import javax.persistence.MapsId; |
9 | import javax.persistence.MapsId; |
| 10 | import javax.persistence.Table; |
10 | import javax.persistence.Table; |
| - | 11 | import javax.validation.constraints.NotNull; |
|
| 11 | 12 | ||
| 12 | import org.hibernate.annotations.ForeignKey; |
13 | import org.hibernate.annotations.ForeignKey; |
| 13 | 14 | ||
| - | 15 | import br.com.ec.core.interfaces.Alterar; |
|
| - | 16 | import br.com.ec.core.interfaces.Cadastrar; |
|
| 14 | import br.com.ec.core.util.VerificadorUtil; |
17 | import br.com.ec.core.util.VerificadorUtil; |
| 15 | 18 | ||
| 16 | @Entity |
19 | @Entity |
| 17 | @Table(name="sec_usuario_loja", schema="sc_sec") |
20 | @Table(name="sec_usuario_loja", schema="sc_sec") |
| 18 | public class UsuarioLoja implements Serializable { |
21 | public class UsuarioLoja implements Serializable { |
| Line 39... | Line 42... | ||
| 39 | 42 | ||
| 40 | @MapsId("sequencialUsuario") |
43 | @MapsId("sequencialUsuario") |
| 41 | @ManyToOne |
44 | @ManyToOne |
| 42 | @ForeignKey(name="fk_usuarioloja_usuario") |
45 | @ForeignKey(name="fk_usuarioloja_usuario") |
| 43 | @JoinColumn(name = "seq_usuario", nullable = false) |
46 | @JoinColumn(name = "seq_usuario", nullable = false) |
| - | 47 | @NotNull(message="Obrigatório informar o usuário", groups={Cadastrar.class, Alterar.class}) |
|
| 44 | public Usuario getUsuario() { |
48 | public Usuario getUsuario() { |
| 45 | if (VerificadorUtil.naoEstaNulo(usuario)) { |
49 | if (VerificadorUtil.naoEstaNulo(usuario)) { |
| 46 | usuarioLojaId.setSequencialUsuario(usuario.getSequencial()); |
50 | usuarioLojaId.setSequencialUsuario(usuario.getSequencial()); |
| 47 | }
|
51 | }
|
| 48 | return usuario; |
52 | return usuario; |
| Line 53... | Line 57... | ||
| 53 | 57 | ||
| 54 | @MapsId("sequencialLoja") |
58 | @MapsId("sequencialLoja") |
| 55 | @ManyToOne |
59 | @ManyToOne |
| 56 | @ForeignKey(name="fk_usuarioloja_loja") |
60 | @ForeignKey(name="fk_usuarioloja_loja") |
| 57 | @JoinColumn(name = "seq_loja", nullable=false) |
61 | @JoinColumn(name = "seq_loja", nullable=false) |
| - | 62 | @NotNull(message="Obrigatório informar a loja", groups={Cadastrar.class, Alterar.class}) |
|
| 58 | public Loja getLoja() { |
63 | public Loja getLoja() { |
| 59 | if (VerificadorUtil.naoEstaNulo(loja)) { |
64 | if (VerificadorUtil.naoEstaNulo(loja)) { |
| 60 | usuarioLojaId.setSequencialLoja(loja.getSequencial()); |
65 | usuarioLojaId.setSequencialLoja(loja.getSequencial()); |
| 61 | }
|
66 | }
|
| 62 | return loja; |
67 | return loja; |