Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package coffeeshop.entity;
- import java.io.Serializable;
- import java.util.List;
- import java.util.Objects;
- import javax.persistence.Basic;
- import javax.persistence.CascadeType;
- import javax.persistence.Column;
- import javax.persistence.Entity;
- import javax.persistence.FetchType;
- import javax.persistence.GeneratedValue;
- import javax.persistence.GenerationType;
- import javax.persistence.Id;
- import javax.persistence.JoinColumn;
- import javax.persistence.JoinTable;
- import javax.persistence.ManyToMany;
- import javax.persistence.ManyToOne;
- import javax.persistence.NamedQueries;
- import javax.persistence.NamedQuery;
- import javax.persistence.Table;
- import javax.xml.bind.annotation.XmlRootElement;
- @Entity
- @Table(name = "order_details")
- @XmlRootElement
- @NamedQueries({
- @NamedQuery(name = "OrderDetails.findAll", query = "SELECT o FROM OrderDetails o")
- , @NamedQuery(name = "OrderDetails.findById", query = "SELECT o FROM OrderDetails o WHERE o.id = :id")
- , @NamedQuery(name = "OrderDetails.findByQuantity", query = "SELECT o FROM OrderDetails o WHERE o.quantity = :quantity")})
- public class OrderDetails implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Basic(optional = false)
- @Column(name = "id")
- private Integer id;
- @JoinColumn(name = "product_id", referencedColumnName = "id")
- @ManyToOne(fetch = FetchType.LAZY)
- private Product product;
- @JoinColumn(name = "order_id", referencedColumnName = "id")
- @ManyToOne(fetch = FetchType.LAZY)
- private Orders orders;
- @Column(name = "quantity")
- private Integer quantity;
- @ManyToMany(cascade = CascadeType.ALL)
- @JoinTable(name = "details_categories",
- joinColumns = {
- @JoinColumn(name = "order_details_id", referencedColumnName = "id")},
- inverseJoinColumns = {
- @JoinColumn(name = "category_id", referencedColumnName = "id")})
- private List<Category> categories;
- @Column(name = "unitprice", precision=4, scale=2)
- private double unitPrice;
- public OrderDetails() {
- }
- public OrderDetails(Integer id) {
- this.id = id;
- }
- public Integer getId() {
- return id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- public Product getProduct() {
- return product;
- }
- public void setProduct(Product product) {
- this.product = product;
- }
- public Orders getOrder() {
- return orders;
- }
- public void setOrder(Orders orders) {
- this.orders = orders;
- }
- public Integer getQuantity() {
- return quantity;
- }
- public void setQuantity(Integer quantity) {
- this.quantity = quantity;
- }
- // @XmlTransient
- public List<Category> getCategories() {
- return categories;
- }
- public void setCategories(List<Category> categories) {
- this.categories = categories;
- }
- public double getUnitPrice() {
- return unitPrice;
- }
- public void setUnitPrice(double unitPrice) {
- this.unitPrice = unitPrice;
- }
- @Override
- public int hashCode() {
- int hash = 0;
- hash += (id != null ? id.hashCode() : 0);
- return hash;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final OrderDetails other = (OrderDetails) obj;
- if (!Objects.equals(this.product, other.product)) {
- return false;
- }
- if (!Objects.equals(this.categories, other.categories)) {
- return false;
- }
- return true;
- }
- @Override
- public String toString() {
- return "coffeeshop.entity.OrderDetails[ id=" + id + " ]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement