Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. package ee.ut.math.tvt.salessystem.dataobjects;
  2.  
  3. import javax.persistence.*;
  4. import java.time.LocalDate;
  5. import java.time.LocalTime;
  6.  
  7. // class used to link SoldItems with a certain Purchase
  8. // required for History Tab to work as intended
  9. // anticipating that we will have a very similar relation in the DB anyways
  10. @Entity
  11. @Table(name = "PURCHASE")
  12. public class Purchase {
  13.  
  14. @Id
  15. @GeneratedValue(strategy = GenerationType.IDENTITY)
  16. private Long id;
  17.  
  18. @Column(name = "LOCALDATE")
  19. private LocalDate localDate;
  20.  
  21. @Column(name = "LOCALTIME")
  22. private LocalTime time;
  23.  
  24. @Column(name = "TOTAL")
  25. private double total;
  26.  
  27. // required by Hibernate
  28. private Purchase() {
  29. }
  30.  
  31. public Purchase(LocalDate localDate, LocalTime time, double total) {
  32. this.localDate = localDate;
  33. this.time = time;
  34. this.total = total;
  35. }
  36.  
  37. public Purchase(long id, LocalDate localDate, LocalTime time, double total) {
  38. this.id = id;
  39. this.localDate = localDate;
  40. this.time = time;
  41. this.total = total;
  42. }
  43.  
  44. public Long getId() {
  45. return id;
  46. }
  47.  
  48. public LocalDate getLocalDate() {
  49. return localDate;
  50. }
  51.  
  52. public String getDate() {
  53. return localDate.toString();
  54. }
  55.  
  56. public String getTime() {
  57. return time.toString();
  58. }
  59.  
  60. public double getTotal() {
  61. return total;
  62. }
  63.  
  64. @Override
  65. public String toString() {
  66. return "Purchase{" +
  67. "id=" + id +
  68. ", localDate=" + localDate +
  69. ", time='" + time + '\'' +
  70. ", total=" + total +
  71. '}';
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement