?? orderitem.java
字號:
package com.foshanshop.ejb3.bean;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class OrderItem implements Serializable {
private static final long serialVersionUID = -1166337687856636179L;
private Integer id;
private String productname;
private Float price;
private Order order;
public OrderItem() {}
public OrderItem(String productname, Float price) {
this.productname = productname;
this.price = price;
}
@Id
@GeneratedValue
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(length=100, nullable=false)
public String getProductname() {
return productname;
}
public void setProductname(String productname) {
this.productname = productname;
}
public Float getPrice() {
return price;
}
public void setPrice(Float price) {
this.price = price;
}
@ManyToOne(cascade=CascadeType.REFRESH, optional=false)
@JoinColumn(name = "order_id")
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
/**
* 返回對象的散列代碼值。該實現(xiàn)根據(jù)此對象
* 中 id 字段計算散列代碼值。
* @return 此對象的散列代碼值。
*/
@Override
public int hashCode() {
int hash = 0;
hash += (this.id != null ? this.id.hashCode() : super.hashCode());
return hash;
}
/**
* 確定其他對象是否等于此 OrderItem。當且僅當
* 參數(shù)不為 null 且該參數(shù)是具有與此對象相同 id 字段值的 OrderItem 對象時,
* 結(jié)果才為 <code>true</code>。
* @param 對象,要比較的引用對象
* 如果此對象與參數(shù)相同,則 @return <code>true</code>;
* 否則為 <code>false</code>。
*/
@Override
public boolean equals(Object object) {
if (!(object instanceof OrderItem)) {
return false;
}
OrderItem other = (OrderItem)object;
if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
return true;
}
/**
* 返回對象的字符串表示法。該實現(xiàn)根據(jù) id 字段
* 構(gòu)造此表示法。
* @return 對象的字符串表示法。
*/
@Override
public String toString() {
return this.getClass().getName()+ "[id=" + id + "]";
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -