| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| package com.acme; |
| |
| import java.io.Serializable; |
| import java.math.BigDecimal; |
| import java.util.Collection; |
| import javax.persistence.CascadeType; |
| import javax.persistence.Column; |
| import javax.persistence.Entity; |
| import javax.persistence.Id; |
| import javax.persistence.JoinColumn; |
| import javax.persistence.ManyToOne; |
| import javax.persistence.NamedQueries; |
| import javax.persistence.NamedQuery; |
| import javax.persistence.OneToMany; |
| import javax.persistence.Table; |
| |
| /** |
| * |
| * @author nam |
| */ |
| @Entity |
| @Table(name = "PRODUCT") |
| @NamedQueries({@NamedQuery(name = "Product.findByProductId", query = "SELECT p FROM Product p WHERE p.productId = :productId"), @NamedQuery(name = "Product.findByPurchaseCost", query = "SELECT p FROM Product p WHERE p.purchaseCost = :purchaseCost"), @NamedQuery(name = "Product.findByQuantityOnHand", query = "SELECT p FROM Product p WHERE p.quantityOnHand = :quantityOnHand"), @NamedQuery(name = "Product.findByMarkup", query = "SELECT p FROM Product p WHERE p.markup = :markup"), @NamedQuery(name = "Product.findByAvailable", query = "SELECT p FROM Product p WHERE p.available = :available"), @NamedQuery(name = "Product.findByDescription", query = "SELECT p FROM Product p WHERE p.description = :description")}) |
| public class Product implements Serializable { |
| @Id |
| @Column(name = "PRODUCT_ID", nullable = false) |
| private Integer productId; |
| @Column(name = "PURCHASE_COST") |
| private BigDecimal purchaseCost; |
| @Column(name = "QUANTITY_ON_HAND") |
| private Integer quantityOnHand; |
| @Column(name = "MARKUP") |
| private BigDecimal markup; |
| @Column(name = "AVAILABLE") |
| private String available; |
| @Column(name = "DESCRIPTION") |
| private String description; |
| @JoinColumn(name = "MANUFACTURER_ID", referencedColumnName = "MANUFACTURER_ID") |
| @ManyToOne |
| private Manufacturer manufacturerId; |
| @JoinColumn(name = "PRODUCT_CODE", referencedColumnName = "PROD_CODE") |
| @ManyToOne |
| private ProductCode productCode; |
| @OneToMany(cascade = CascadeType.ALL, mappedBy = "productId") |
| private Collection<PurchaseOrder> purchaseOrderCollection; |
| |
| public Product() { |
| } |
| |
| public Product(Integer productId) { |
| this.productId = productId; |
| } |
| |
| public Integer getProductId() { |
| return productId; |
| } |
| |
| public void setProductId(Integer productId) { |
| this.productId = productId; |
| } |
| |
| public BigDecimal getPurchaseCost() { |
| return purchaseCost; |
| } |
| |
| public void setPurchaseCost(BigDecimal purchaseCost) { |
| this.purchaseCost = purchaseCost; |
| } |
| |
| public Integer getQuantityOnHand() { |
| return quantityOnHand; |
| } |
| |
| public void setQuantityOnHand(Integer quantityOnHand) { |
| this.quantityOnHand = quantityOnHand; |
| } |
| |
| public BigDecimal getMarkup() { |
| return markup; |
| } |
| |
| public void setMarkup(BigDecimal markup) { |
| this.markup = markup; |
| } |
| |
| public String getAvailable() { |
| return available; |
| } |
| |
| public void setAvailable(String available) { |
| this.available = available; |
| } |
| |
| public String getDescription() { |
| return description; |
| } |
| |
| public void setDescription(String description) { |
| this.description = description; |
| } |
| |
| public Manufacturer getManufacturerId() { |
| return manufacturerId; |
| } |
| |
| public void setManufacturerId(Manufacturer manufacturerId) { |
| this.manufacturerId = manufacturerId; |
| } |
| |
| public ProductCode getProductCode() { |
| return productCode; |
| } |
| |
| public void setProductCode(ProductCode productCode) { |
| this.productCode = productCode; |
| } |
| |
| public Collection<PurchaseOrder> getPurchaseOrderCollection() { |
| return purchaseOrderCollection; |
| } |
| |
| public void setPurchaseOrderCollection(Collection<PurchaseOrder> purchaseOrderCollection) { |
| this.purchaseOrderCollection = purchaseOrderCollection; |
| } |
| |
| @Override |
| public int hashCode() { |
| int hash = 0; |
| hash += (productId != null ? productId.hashCode() : 0); |
| return hash; |
| } |
| |
| @Override |
| public boolean equals(Object object) { |
| // TODO: Warning - this method won't work in the case the id fields are not set |
| if (!(object instanceof Product)) { |
| return false; |
| } |
| Product other = (Product) object; |
| if (this.productId != other.productId && (this.productId == null || !this.productId.equals(other.productId))) { |
| return false; |
| } |
| return true; |
| } |
| |
| @Override |
| public String toString() { |
| return "test.Product[productId=" + productId + "]"; |
| } |
| |
| } |