Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ee.ut.math.tvt.salessystem.dataobjects;
- import javax.persistence.*;
- import java.time.LocalDate;
- import java.time.LocalTime;
- // class used to link SoldItems with a certain Purchase
- // required for History Tab to work as intended
- // anticipating that we will have a very similar relation in the DB anyways
- @Entity
- @Table(name = "PURCHASE")
- public class Purchase {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
- @Column(name = "LOCALDATE")
- private LocalDate localDate;
- @Column(name = "LOCALTIME")
- private LocalTime time;
- @Column(name = "TOTAL")
- private double total;
- // required by Hibernate
- private Purchase() {
- }
- public Purchase(LocalDate localDate, LocalTime time, double total) {
- this.localDate = localDate;
- this.time = time;
- this.total = total;
- }
- public Purchase(long id, LocalDate localDate, LocalTime time, double total) {
- this.id = id;
- this.localDate = localDate;
- this.time = time;
- this.total = total;
- }
- public Long getId() {
- return id;
- }
- public LocalDate getLocalDate() {
- return localDate;
- }
- public String getDate() {
- return localDate.toString();
- }
- public String getTime() {
- return time.toString();
- }
- public double getTotal() {
- return total;
- }
- @Override
- public String toString() {
- return "Purchase{" +
- "id=" + id +
- ", localDate=" + localDate +
- ", time='" + time + '\'' +
- ", total=" + total +
- '}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement