Hi Jose,
I am coping, the entire code stuffs, go thro it and give a solution, package dept;
REMOTE INTERFACE
/**
* The remote interface of the MyDept entity bean.
*/
import java.rmi.*;
import javax.ejb.*;
public interface MyDept extends EJBObject {
String[] getRecord() throws RemoteException;
}
HOME INTERFACE
package dept;
/**
* The home interface of the MyDept entity bean.
**/
import java.rmi.*;
import java.util.*;
import javax.ejb.*;
public interface MyDeptHome extends javax.ejb.EJBHome {
MyDept create(MyDeptKey id) throws CreateException, RemoteException;
MyDept create(MyDeptKey id, String deptName) throws CreateException, RemoteException;
public MyDept findByPrimaryKey(MyDeptKey id) throws RemoteException, FinderException;
Enumeration findByDepartmentName(String deptName) throws RemoteException, FinderException;
}
FINDER HELPER CLASS
package dept;
/**
* The finder helper interface of the MyAccount entity bean.
* For each finder method defined in the home interface other than the create and
* findByPrimaryKey methods, a query Sting must be defined here.
*
* These query strings will be referenced by the finder implementation class generated by the
* deployment tool.
**/
public interface MyDeptBeanFinderHelper {
public static final String findByDepartmentNameQueryString = "select * from ejb.MyDeptBeantbl where deptName=?";
}
KEY CLASS
package dept;
/**
* The key class of the MyDept entity bean.
**/
import java.io.*;
public class MyDeptKey implements Serializable {
public long deptNo;
/**
* Constructs an MyDeptKey object.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public MyDeptKey() {
super();
}
/**
* Constructs a newly allocated MyDeptBMKey object that represents the primitive long argument.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public MyDeptKey(long deptNo) {
this.deptNo = deptNo;
}
public long asLong() {
return deptNo;
}
/**
* Determines if the MyDeptKey object passed to the method matches this MyAccountKey object.
* @param o java.lang.Object The MyDeptKey object to compare to this MyAccountKey object.
* @return boolean The pass object is either equal to this MyDeptBMKey object (true) or
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public boolean equals(Object o) {
if (o instanceof MyDeptKey) {
MyDeptKey otherKey = (MyDeptKey) o;
return (((deptNo == otherKey.deptNo)));
}
else {
return false;
}
}
/**
* Generates a hash code for this MyDeptKey object.
* @return int The hash code.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
public int hashCode() {
return ((new Long(deptNo).hashCode()));
}
}
BEAN CLASS
package dept;
/**
* The bean class of the MyAccount entity bean.
**/
import java.rmi.RemoteException;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.ListResourceBundle;
import javax.ejb.*;
import java.lang.*;
public class MyDeptBean implements EntityBean {
private EntityContext entityContext = null;
public long deptNo = 0;
public String deptName;
public void ejbActivate() throws RemoteException { }
public void ejbCreate(MyDeptKey key) {
ejbCreate(key, "Sales" );
}
public void ejbCreate(MyDeptKey key, String deptName) {
deptNo = key.deptNo;
this.deptName= deptName;
}
public void ejbLoad () throws RemoteException { }
public void ejbPassivate() throws RemoteException { }
public void ejbPostCreate(MyDeptKey key) throws RemoteException {
ejbPostCreate(key, "Sales" );
}
public void ejbPostCreate(MyDeptKey key, String deptName) { }
public void ejbRemove() throws RemoteException { }
public void ejbStore () throws RemoteException { }
public String [] getRecord() {
String s[] = new String[2];
s[0]=""+deptNo;
s[1]=deptName;
return s;
}
public void setEntityContext(EntityContext ctx) throws RemoteException {
entityContext = ctx;
}
public void unsetEntityContext() throws RemoteException {
entityContext = null;
}
}