用一个包装类做为主键.在ejbCreate时,用两个字段的值生成包装类.
ejbActivate时,通过EntityContext.getPrimaryKey()来得到该包装类,从中得到两个字段的值,根据这两个字段的值从数据库中查找记录!
ejbActivate时,通过EntityContext.getPrimaryKey()来得到该包装类,从中得到两个字段的值,根据这两个字段的值从数据库中查找记录!
解决方案 »
- jsp form表单如何同时post到两个jsp页面
- servlet中怎么获取webroot下的一个文件夹的路径
- 这两句代码是神马意思?
- MyEclipse有自带的tomcat吗?????
- 下面是我反转dao 自动生成的一些类 帮忙讲解一下 各个方法的的含义 在什么时候用
- JS中的一个小问题
- 使用jfreechart做曲线图时,如何设置x轴和y轴的长度?如何设置纵坐标的初始值,比如我想把起点设置为500,间隔单位为2
- 如何给菜单加上类似“Del”的名字
- 突然想问啥是业务-.-#
- Applet 的在IE6.0的中文问题 在线等待,急!急!急! 高分
- 希望对java了解比较深的人给我答案
- 求助:关于query的返回值
用的时候要在配置文件中配置该类。
//出自精通EJB第三版/**
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 2005-4-23
* Time: 15:03:53
* To change this template use File | Settings | File Templates.
*/
public class AccountPK implements java.io.Serializable{
public String accountID; public AccountPK() {
} public AccountPK(String accountID) {
this.accountID=accountID;
} public int hashCode(){
return accountID.hashCode();
} public String toString(){
return "account:"+accountID;
} public boolean equals(Object accountPK){
if(!(accountPK instanceof AccountPK)) return false;
return (((AccountPK)accountPK).accountID).equals(accountID);
}
}
比如String s1,s2;//s1,s2是你的字段名
public int hashCode(){
return s1.hashCode()^s2.hashCode();
}