HibernateBean的写法,有单一主键,复合主键


/**
* @hibernate.class table="pwmip.pwmip_CastChannel"
*/
public class pwmip_CastChannel
{
private int ASNo;

private ServerInfo id;



public pwmip_CastChannel(){

}


/**
* @hibernate.id class="ServerInfo"
*/

public ServerInfo getId() {
return id;
}


public void setId(ServerInfo id) {
if(id!=null)
{
if(id.getASNo()!=null)
this.ASNo=id.getASNo().intValue();

if(id.getCastChannelNo()!=null)
this.CastChannelNo=id.getCastChannelNo().intValue();

if(id.getServerNo()!=null)
this.ServerNo=id.getServerNo().intValue();

}
this.id = id;
}
public int getASNo(){
return this.ASNo;
}

public void setASNo(int ASNo){
if(id==null)

id=new ServerInfo();

id.setASNo(new Integer(ASNo));



this.ASNo=ASNo;
}

public int getCastChannelNo(){
return this.CastChannelNo;
}

public void setCastChannelNo(int CastChannelNo){

if(id==null)

id=new ServerInfo();

id.setCastChannelNo(new Integer(CastChannelNo));

this.CastChannelNo=CastChannelNo;
}

public int getServerNo(){
return this.ServerNo;
}

public void setServerNo(int ServerNo){

if(id==null)

id=new ServerInfo();

id.setServerNo(new Integer(ServerNo));

this.ServerNo=ServerNo;
}

/**
* @hibernate.property column="CastChannelName"
*/
public String getCastChannelName(){
return this.CastChannelName;
}



}


/**
*
*/


import java.io.Serializable;

/**
* @author zhenjw
*
*/
public class ServerInfo implements Serializable {

// Fields

private Integer ASNo;
private Integer CastChannelNo;
private Integer ServerNo;



/** default constructor */
public ServerInfo() {
}


/** full constructor */
public ServerInfo(Integer ASNo, Integer CastChannelNo) {
this.ASNo = ASNo;
this.CastChannelNo = CastChannelNo;
}


// Property accessors

/**
* @hibernate.property column="ASNo"
*/
public Integer getASNo() {
return this.ASNo;
}

public void setASNo(Integer ASNo) {
this.ASNo = ASNo;
}

/**
* @hibernate.property column="CastChannelNo"
*
*/
public Integer getCastChannelNo() {
return this.CastChannelNo;
}

public void setCastChannelNo(Integer CastChannelNo) {
this.CastChannelNo = CastChannelNo;
}

/**
* @hibernate.property column="ServerNo"
*
*/
public Integer getServerNo() {
return ServerNo;
}


public void setServerNo(Integer serverNo) {
ServerNo = serverNo;
}


public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
final ServerInfo other = (ServerInfo) obj;
if (ASNo == null) {
if (other.ASNo != null)
return false;
} else if (!ASNo.equals(other.ASNo))
return false;
if (CastChannelNo == null) {
if (other.CastChannelNo != null)
return false;
} else if (!CastChannelNo.equals(other.CastChannelNo))
return false;
if (ServerNo == null) {
if (other.ServerNo != null)
return false;
} else if (!ServerNo.equals(other.ServerNo))
return false;
return true;
}

public int hashCode() {
final int PRIME = 31;
int result = super.hashCode();
result = PRIME * result + ((ASNo == null) ? 0 : ASNo.hashCode());
result = PRIME * result + ((CastChannelNo == null) ? 0 : CastChannelNo.hashCode());
result = PRIME * result + ((ServerNo == null) ? 0 : ServerNo.hashCode());
return result;
}


}

这只是一个样例,没有时间调了,有时间再进行修改,先备份了。
搬家之后不能上网很郁闷啊!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值