Advertisement
paulito81

Java @Entity persist with @OneToOne problem.1

Nov 15th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1.  
  2. @Entity
  3. @NamedQuery(name = "Customer.getAll", query = "SELECT c FROM Customer c")
  4. @SequenceGenerator(name = "SEQ_CUST", initialValue = 50)
  5. public class Customer {
  6.  
  7. // ======================================
  8. // = Attributes =
  9. // ======================================
  10.  
  11. @Id
  12. @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_CUST")
  13. @Cascade(CascadeType.ALL)
  14. @Column(name = "FK_CUSTOMER")
  15. private int id;
  16. @NotNull
  17. private String firstName;
  18. @NotNull
  19. private String lastName;
  20. @NotNull
  21. private String email;
  22. @NotNull
  23. private String phoneNumber;
  24. @NotNull
  25. private Date birth;
  26.  
  27. public Customer(){
  28. }
  29.  
  30. public Customer(String firstName, String lastName, String email, String phoneNumber, Date birth) {
  31. this.firstName = firstName;
  32. this.lastName = lastName;
  33. this.email = email;
  34. this.phoneNumber = phoneNumber;
  35. this.birth = birth;
  36. }
  37. public int getId() {
  38. return id;
  39. }
  40.  
  41. public void setId(int id) {
  42. this.id = id;
  43. }
  44.  
  45. public String getFirstName() {
  46. return firstName;
  47. }
  48.  
  49. public void setFirstName(String firstName) {
  50. this.firstName = firstName;
  51. }
  52.  
  53. public String getLastName() {
  54. return lastName;
  55. }
  56.  
  57. public void setLastName(String lastName) {
  58. this.lastName = lastName;
  59. }
  60.  
  61. public String getEmail() {
  62. return email;
  63. }
  64.  
  65. public void setEmail(String email) {
  66. this.email = email;
  67. }
  68.  
  69. public String getPhoneNumber() {
  70. return phoneNumber;
  71. }
  72.  
  73. public void setPhoneNumber(String phoneNumber) {
  74. this.phoneNumber = phoneNumber;
  75. }
  76.  
  77. public Date getBirth() {
  78. return birth;
  79. }
  80.  
  81. public void setBirth(Date birth) {
  82. this.birth = birth;
  83. }
  84. @Override
  85. public String toString() {
  86. return "Customer{" +
  87. "customerId=" + id +
  88. ", firstName='" + firstName + '\'' +
  89. ", lastName='" + lastName + '\'' +
  90. ", email='" + email + '\'' +
  91. ", phoneNumber='" + phoneNumber + '\'' +
  92. ", birth=" + birth +
  93. '}';
  94. }
  95.  
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement