日期:2014-05-18 浏览次数:20842 次
/**
* 所有model的基类
* @author chenas
*2013年08月11日
*/
@Entity
public class BaseModel {
//主键
public long id;
@Id
@GeneratedValue
@Override
public long getId() {
return id;
}
@Override
public void setId(long id) {
this.id = id;
}
}
@Entity(name="BUYER_USER")
public class BuyerUser extends BaseModel{
private String username;
private String password;
private long addrId;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public long getAddrId() {
return addrId;
}
public void setAddrId(long addrId) {
this.addrId = addrId;
}
}
@Entity(name="Shop_USER")
public class ShopUser extends BaseModel{
private String username;
private String password;
private long addrId;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public long getAddrId() {
return addrId;
}
public void setAddrId(long addrId) {
this.addrId = addrId;
}
}
<mapping class="com.eshop.model.BuyerUser"/>
<mapping class="com.eshop.model.ShopUser"/>
new SchemaExport(new AnnotationConfiguration().configure()).create(true, true);