Guest User

Untitled

a guest
Jun 27th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. package br.com.arena.model;
  2.  
  3. import java.io.Serializable;
  4. import java.util.List;
  5.  
  6. import javax.persistence.CascadeType;
  7. import javax.persistence.Column;
  8. import javax.persistence.Entity;
  9. import javax.persistence.EnumType;
  10. import javax.persistence.Enumerated;
  11. import javax.persistence.GeneratedValue;
  12. import javax.persistence.GenerationType;
  13. import javax.persistence.Id;
  14. import javax.persistence.OneToMany;
  15.  
  16. import br.com.arena.enumerador.Cargo;
  17. import javax.faces.bean.ManagedBean;
  18.  
  19.  
  20. //Especificar que essa classe e uma entidade do banco - @entity
  21. @ManagedBean
  22. @Entity
  23. public class Pessoa implements Serializable{
  24.  
  25. /**
  26. *
  27. */
  28. private static final long serialVersionUID = 1L;
  29.  
  30. @Id
  31. @GeneratedValue(strategy = GenerationType.IDENTITY)
  32. @Column (name="id_Pessoa")
  33. private Integer id;
  34.  
  35. @Column(nullable=false)
  36. private String nomeUsuario;
  37.  
  38. @Column(nullable=true)
  39. private String nomeCompleto;
  40.  
  41. @Column(nullable=true)
  42. private String email;
  43.  
  44. @Column(nullable=true)
  45. private int idade;
  46.  
  47. @OneToMany(mappedBy="pessoa",cascade=CascadeType.ALL)
  48. private List<Pessoa_Time> times;
  49.  
  50. public Pessoa (){}
  51.  
  52. public Pessoa (Pessoa pessoa){
  53. this.id = pessoa.getId();
  54. this.nomeUsuario = pessoa.getNomeUsuario();
  55. this.nomeCompleto = pessoa.getNomeCompleto();
  56. this.email = pessoa.getEmail();
  57. this.idade = pessoa.getIdade();
  58. }
  59.  
  60.  
  61.  
  62. public Integer getId() {
  63. return id;
  64. }
  65.  
  66. public void setId(Integer id) {
  67. this.id = id;
  68. }
  69.  
  70. public String getNomeUsuario() {
  71. return nomeUsuario;
  72. }
  73.  
  74. public void setNomeUsuario(String nomeUsuario) {
  75. this.nomeUsuario = nomeUsuario;
  76. }
  77.  
  78. public String getNomeCompleto() {
  79. return nomeCompleto;
  80. }
  81.  
  82. public void setNomeCompleto(String nomeCompleto) {
  83. this.nomeCompleto = nomeCompleto;
  84. }
  85.  
  86. public String getEmail() {
  87. return email;
  88. }
  89.  
  90. public void setEmail(String email) {
  91. this.email = email;
  92. }
  93.  
  94. public int getIdade() {
  95. return idade;
  96. }
  97.  
  98. public void setIdade(int idade) {
  99. this.idade = idade;
  100. }
  101.  
  102. public List<Pessoa_Time> getTimes() {
  103. return times;
  104. }
  105.  
  106. public void setTimes(List<Pessoa_Time> times) {
  107. this.times = times;
  108. }
  109.  
  110. @Override
  111. public String toString() {
  112. return "Pessoa [id=" + id + ", nomeUsuario=" + nomeUsuario + ", nomeCompleto=" + nomeCompleto + ", email="
  113. + email + ", idade=" + idade + ", times=" + times + "]";
  114. }
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124. }
Add Comment
Please, Sign In to add comment