关于编写entityBean是出现的问题,请大家帮
还有我想问一下,我用的是oracle,在编写一个测试的ejb。我用sessionBean和entityBean来对数据进行操作,sessionBean中我定义一个新的方法:getEmpName(short empNo) empNo为主关键字,以下是我写的代码:
String empName="name not found";
try {
javax.naming.Context context = new javax.naming.InitialContext();
Object object = context.lookup("oraDataSource");//oraDataSource在weblogic中已经配好了
EmployeeHome empHome = (EmployeeHome) javax.rmi.PortableRemoteObject.narrow(object,
EmployeeHome.class);
Employee emp = empHome.findByPrimaryKey(empNo);
empName = emp.getFirstName() + " " + emp.getLastName();
}catch (Exception ex) {
ex.printStackTrace();
}
return empName
可是为什么老是报错:
Method findByPrimaryKey(short) not found in interface testentity.EmployeeHome
而且我在后面的的testClient中加入的代码:
EmpSecTestClient client = new EmpSecTestClient();
try {
client.create();
String empName = client.getEmpName(new Short("2"));
System.out.println("Employee Name from the Test Client is = " + empName);
}
catch (Exception ex) {
ex.printStackTrace();
}
中也出现:
Method getEmpName(java.lang.Short) not found in class testentity.EmpSecTestClient
调了很久也没有成功!请看看,帮个忙把!:D