📄 item.java
字号:
/*
* Copyright 2006 Borys Burnayev
*
* Licensed 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.rdacorp.petstore.domain;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Version;
/**
* @author Borys Burnayev
*/
@Entity
@Table(name = "item")
@SequenceGenerator(name = "ItemSeq", sequenceName = "sq_item")
@SecondaryTable(name = "sku", pkJoinColumns = @PrimaryKeyJoinColumn(name = "item_sysid"))
public class Item {
private Integer itemId;
private String code;
private String description;
private String imagePath;
private Product product;
private BigDecimal price;
private Integer availableQuantity;
private int version;
@Column(name = "row_version")
@Version
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public Item(String code, String description, String imagePath, BigDecimal price, Integer availableQuantity,
Product product) {
this.code = code;
this.description = description;
this.imagePath = imagePath;
this.price = price;
this.availableQuantity = availableQuantity;
this.product = product;
}
public Item() {
}
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ItemSeq")
@Column(name = "item_sysid")
public Integer getItemId() {
return this.itemId;
}
public void setItemId(Integer itemSysid) {
this.itemId = itemSysid;
}
@Column(name = "item_abbr")
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
@Column(name = "item_desc")
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
@Column(name = "image_path")
public String getImagePath() {
return this.imagePath;
}
public void setImagePath(String imagePath) {
this.imagePath = imagePath;
}
@ManyToOne
@JoinColumn(name = "product_sysid", referencedColumnName = "product_sysid")
public Product getProduct() {
return this.product;
}
public void setProduct(Product product) {
this.product = product;
}
@Column(table = "sku", name = "unit_pr")
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
@Column(table = "sku", name = "available_qt")
public Integer getAvailableQuantity() {
return availableQuantity;
}
public void setAvailableQuantity(Integer availableQuantity) {
this.availableQuantity = availableQuantity;
}
public String toString() {
String id = itemId != null ? itemId.toString() : "<no ID>";
return "Item " + id + ":\nCode: " + code + "\nDescription: " + description + "\nPrice: " + price
+ "\nAvailable Quantity: " + availableQuantity + "\nImage Path: " + imagePath + "\n" + product;
}
public boolean equals(Object object) {
if (!(object instanceof Item))
return false;
Item item = (Item) object;
return code.equals(item.getCode());
}
public int hashCode() {
return code.hashCode();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -