站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题我的CMP 中有两个主键,怎么调用它的 findByPrimaryKey

我的CMP 中有两个主键,怎么调用它的 findByPrimaryKey

摘要: 我的CMP 中有两个主键,怎么调用它的 findByPrimaryKey


String substaid, String lineid,String linename, BigDecimal voltagein,Integer ismaster

我有的是SQLSERVER数据库,这个表中有两个主键(String substaid, String lineid),我要在其它的方法中调用findByPrimaryKey 怎么写啊

public LineinfoRemote createAll(String substaid, String lineid,
String linename, BigDecimal voltagein,
Integer ismaster) throws CreateException, RemoteException;

public LineinfoRemote findByPrimaryKey(LineinfoPK pk) throws FinderException,
RemoteException;



你先用substaid和lineid创建一个LineinfoPK对象,然后再调用findByPrimaryKey方法。
你试试看!


刚学,还不太懂,
这是我EJB里自动产生的

public class LineinfoPK
implements Serializable {
public String substaid;
public String lineid;
public LineinfoPK() {
}

public LineinfoPK(String substaid, String lineid) {
this.substaid = substaid;
this.lineid = lineid;
}

public boolean equals(Object obj) {
if (this == obj)
return true;
if (! (obj instanceof LineinfoPK))
return false;
LineinfoPK that = (LineinfoPK) obj;
if (! (that.substaid == null ? this.substaid == null :
that.substaid.equals(this.substaid)))
return false;
if (! (that.lineid == null ? this.lineid == null :
that.lineid.equals(this.lineid)))
return false;
return true;
}

public int hashCode() {
int result = 17;
result = 37 * result + this.substaid.hashCode();
result = 37 * result + this.lineid.hashCode();
return result;
}
}


这是调用的地方, 在下面这句话中有错
LineinfoRemote ejb = Lineinfohome.findByPrimaryKey(pk);

public int deleteLineinfo(String substaid, String lineid) {
int back = -1;
LineinfoPK pk=new LineinfoPK(substaid,lineid);
LineinfoRemote ejb = Lineinfohome.findByPrimaryKey(pk);
return 0;
}


搞定,忘加try 块 了

全当散分了


↑返回目录
前一篇: 循环输出table记录时,如果记录为null,不出现表格的边线的问题
后一篇: 急问题:请教Eclipse+MyEclipse+Tomcat5的配置问题,谢谢!