?? person.java
字號:
package com.foshanshop.ejb3.bean;
import java.io.Serializable;
import java.util.Date;
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.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
public class Person implements Serializable{
private static final long serialVersionUID = 8305710085432450318L;
private Integer personid;
private String name;
private boolean sex;
private Short age;
private Date birthday;
private IDCard idcard;
@Id
@GeneratedValue
public Integer getPersonid() {
return personid;
}
public void setPersonid(Integer personid) {
this.personid = personid;
}
@Column(name = "PersonName",nullable=false,length=32)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(nullable=false)
public boolean getSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
@Column(nullable=false)
public Short getAge() {
return age;
}
public void setAge(Short age) {
this.age = age;
}
@Temporal(value=TemporalType.DATE)
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
@OneToOne(optional = true, cascade = CascadeType.ALL)
@JoinColumn(name = "idcard_id", unique = true)
public IDCard getIdcard() {
return idcard;
}
public void setIdcard(IDCard idcard) {
this.idcard = idcard;
}
/**
* 返回對象的散列代碼值。該實現(xiàn)根據(jù)此對象
* 中 personid 字段計算散列代碼值。
* @return 此對象的散列代碼值。
*/
@Override
public int hashCode() {
int hash = 0;
hash += (this.personid != null ? this.personid.hashCode() : 0);
return hash;
}
/**
* 確定其他對象是否等于此 Person。當(dāng)且僅當(dāng)
* 參數(shù)不為 null 且該參數(shù)是具有與此對象相同 personid 字段值的 Person 對象時,
* 結(jié)果才為 <code>true</code>。
* @param 對象,要比較的引用對象
* 如果此對象與參數(shù)相同,則 @return <code>true</code>;
* 否則為 <code>false</code>。
*/
@Override
public boolean equals(Object object) {
if (!(object instanceof Person)) {
return false;
}
Person other = (Person)object;
if (this.personid != other.personid && (this.personid == null || !this.personid.equals(other.personid))) return false;
return true;
}
/**
* 返回對象的字符串表示法。該實現(xiàn)根據(jù) personid 字段
* 構(gòu)造此表示法。
* @return 對象的字符串表示法。
*/
@Override
public String toString() {
return this.getClass().getName()+ "[personid=" + personid+ "]";
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -