?? idcard.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.OneToOne;
@Entity
public class IDCard implements Serializable{
private static final long serialVersionUID = -4610000117411667607L;
private Integer id;
private String cardno;
private Person person;
public IDCard() {}
public IDCard(String cardno) {
this.cardno = cardno;
}
@Id
@GeneratedValue
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Column(nullable=false,length=18,unique = true)
public String getCardno() {
return cardno;
}
public void setCardno(String cardno) {
this.cardno = cardno;
}
@OneToOne(optional = false, cascade = CascadeType.REFRESH, mappedBy = "idcard")
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
/**
* 返回對象的散列代碼值。該實現根據此對象
* 中 id 字段計算散列代碼值。
* @return 此對象的散列代碼值。
*/
@Override
public int hashCode() {
int hash = 0;
hash += (this.id != null ? this.id.hashCode() : 0);
return hash;
}
/**
* 確定其他對象是否等于此 IDCard。當且僅當
* 參數不為 null 且該參數是具有與此對象相同 id 字段值的 IDCard 對象時,
* 結果才為 <code>true</code>。
* @param 對象,要比較的引用對象
* 如果此對象與參數相同,則 @return <code>true</code>;
* 否則為 <code>false</code>。
*/
@Override
public boolean equals(Object object) {
if (!(object instanceof IDCard)) {
return false;
}
IDCard other = (IDCard)object;
if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false;
return true;
}
/**
* 返回對象的字符串表示法。該實現根據 id 字段
* 構造此表示法。
* @return 對象的字符串表示法。
*/
@Override
public String toString() {
return this.getClass().getName()+ "[id=" + id + "]";
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -