content: package com.adyen.demo.store.domain;
  
  import java.io.Serializable;
  import java.math.BigDecimal;
  import javax.persistence.*;
  import javax.validation.constraints.DecimalMin;
  import javax.validation.constraints.Min;
  import javax.validation.constraints.NotNull;
  import org.hibernate.annotations.Cache;
  import org.hibernate.annotations.CacheConcurrencyStrategy;
  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  
  /**
   * A ProductOrder.
   */
  @Entity
  @Table(name = "product_order")
  @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
  public class ProductOrder implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @NotNull
      @Min(value = 0)
      @Column(name = "quantity", nullable = false)
      private Integer quantity;
  
      @NotNull
      @DecimalMin(value = "0")
      @Column(name = "total_price", precision = 21, scale = 2, nullable = false)
      private BigDecimal totalPrice;
  
      @ManyToOne(optional = false)
      @NotNull
      @JsonIgnoreProperties(value = { "productOrders" }, allowSetters = true)
      private Product product;
  
      @ManyToOne(optional = false)
      @NotNull
      @JsonIgnoreProperties(value = { "orders" }, allowSetters = true)
      private ShoppingCart cart;
  
      // jhipster-needle-entity-add-field - JHipster will add fields here
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public ProductOrder id(Long id) {
          this.id = id;
          return this;
      }
  
      public Integer getQuantity() {
          return this.quantity;
      }
  
      public ProductOrder quantity(Integer quantity) {
          this.quantity = quantity;
          return this;
      }
  
      public void setQuantity(Integer quantity) {
          this.quantity = quantity;
      }
  
      public BigDecimal getTotalPrice() {
          return this.totalPrice;
      }
  
      public ProductOrder totalPrice(BigDecimal totalPrice) {
          this.totalPrice = totalPrice;
          return this;
      }
  
      public void setTotalPrice(BigDecimal totalPrice) {
          this.totalPrice = totalPrice;
      }
  
      public Product getProduct() {
          return this.product;
      }
  
      public ProductOrder product(Product product) {
          this.setProduct(product);
          return this;
      }
  
      public void setProduct(Product product) {
          this.product = product;
      }
  
      public ShoppingCart getCart() {
          return this.cart;
      }
  
      public ProductOrder cart(ShoppingCart shoppingCart) {
          this.setCart(shoppingCart);
          return this;
      }
  
      public void setCart(ShoppingCart shoppingCart) {
          this.cart = shoppingCart;
      }
  
      // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here
  
      @Override
      public boolean equals(Object o) {
          if (this == o) {
              return true;
          }
          if (!(o instanceof ProductOrder)) {
              return false;
          }
          return id != null && id.equals(((ProductOrder) o).id);
      }
  
      @Override
      public int hashCode() {
          // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
          return getClass().hashCode();
      }
  
      // prettier-ignore
      @Override
      public String toString() {
          return "ProductOrder{" +
              "id=" + getId() +
              ", quantity=" + getQuantity() +
              ", totalPrice=" + getTotalPrice() +
              "}";
      }
  }
  