Advertisement
Guest User

Untitled

a guest
Oct 18th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package entities;
  7.  
  8. import java.io.Serializable;
  9. import java.util.List;
  10. import javax.persistence.Entity;
  11. import javax.persistence.GeneratedValue;
  12. import javax.persistence.GenerationType;
  13. import javax.persistence.Id;
  14. import javax.persistence.JoinColumn;
  15. import javax.persistence.ManyToOne;
  16. import javax.persistence.NamedQueries;
  17. import javax.persistence.NamedQuery;
  18. import javax.persistence.Table;
  19. import javax.validation.constraints.NotNull;
  20. import javax.validation.constraints.Pattern;
  21.  
  22. /**
  23. *
  24. * @author emanuelx
  25. */
  26. @NamedQueries({
  27. @NamedQuery(name = "getAllStudents",
  28. query = "SELECT s FROM Student s order by s.name"),})
  29. @Entity
  30. @Table(name="STUDENTS")
  31. public class Student implements Serializable {
  32.  
  33. @Id
  34. @NotNull
  35. private String username;
  36. @NotNull
  37. private String password;
  38. @NotNull
  39. private String name;
  40. @Pattern(regexp = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\."
  41. + "[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"
  42. + "(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
  43. message = "{invalid.email}")
  44. @NotNull
  45. private String email;
  46. @ManyToOne
  47. @JoinColumn(name="COURSE_CODE")
  48. @NotNull
  49. private Course course;
  50.  
  51.  
  52. public Student() {
  53. }
  54.  
  55. public Student(String username, String password, String name, String email, Course course) {
  56. this.username = username;
  57. this.password = password;
  58. this.name = name;
  59. this.email = email;
  60. this.course = course;
  61. }
  62.  
  63. public String getUsername() {
  64. return username;
  65. }
  66.  
  67. public void setUsername(String username) {
  68. this.username = username;
  69. }
  70.  
  71. public String getPassword() {
  72. return password;
  73. }
  74.  
  75. public void setPassword(String password) {
  76. this.password = password;
  77. }
  78.  
  79. public String getName() {
  80. return name;
  81. }
  82.  
  83. public void setName(String name) {
  84. this.name = name;
  85. }
  86.  
  87. public String getEmail() {
  88. return email;
  89. }
  90.  
  91. public void setEmail(String email) {
  92. this.email = email;
  93. }
  94.  
  95. public Course getCourse() {
  96. return course;
  97. }
  98.  
  99. public void setCourse(Course course) {
  100. this.course = course;
  101. }
  102.  
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement