hi everyone,
I have written these interfaces and classes. i am deploying my application using wl deployer tool. i have included the home interface, remote interface , primarykey class and the bean interface in the deployer tool. i am selecting the persistance for all the three fields viz name,id,salary.
when i am trying to deploy it gives a error saying
"n EJB Employee, the home interface must define the findByPrimaryKey method."
thanx a lot.....................
here is my code
---------------------
Home interface :::
---------------------------------------------------------
package examples.ejb.basic.containerManaged;
import java.rmi.*;
import javax.ejb.*;
public interface EmployeeHome extends EJBHome
{
Employee create(String id,String name,float salary) throws RemoteException,CreateException;
public Employee findByPrimaryKey(EmployeePK pk) throws RemoteException,FinderException;
}
------------------------------------------------------------Remote interface
----------------------------------------------------------
package examples.ejb.basic.containerManaged;
import java.rmi.*;
import javax.ejb.*;
public interface Employee extends EJBObject
{
float getSalary() throws RemoteException;
void setSalary(float f) throws RemoteException;
}
------------------------------------------------------------
beanclass
-----------------------------------------------------------
package examples.ejb.basic.containerManaged;
import java.rmi.*;
import javax.ejb.*;
public class EmployeeBean implements EntityBean
{
public String id;
public String name;
public float salary;
private EntityContext ec;
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public void ejbLoad(){}
public void ejbStore(){}
public void setEntityContext(EntityContext ec)
{
this.ec = ec;
}
public void unsetEntityContext()
{
this.ec = null;
}
public String ejbCreate(String id,String name,float salary)
{
this.id = id;
this.name = name;
this.salary = salary;
return null;
}
public void ejbPostCreate(String id,String name,float salary)
{
}
public float getSalary()
{
return this.salary;
}
public void setSalary(float f)
{
this.salary = f;
}
public boolean isModified()
{
return true;
}
}
------------------------------------------------------------primarykey class
----------------------------------------------------------
package examples.ejb.basic.containerManaged;
import java.io.Serializable;
public class EmployeePK implements java.io.Serializable
{
public String Employeeid;
public EmployeePK(String Employeeid)
{
this.Employeeid = Employeeid;
}
public EmployeePK()
{
}
public String toString()
{
return Employeeid.toString();
}
}
------------------------------------------------------------
-
Please check my code (4 messages)
- Posted by: mahadevan venkata
- Posted on: January 08 2001 12:55 EST
Threaded Messages (4)
- change yr code by Rinku Razdan on January 09 2001 00:36 EST
- change yr code by mahadevan venkata on January 09 2001 05:06 EST
-
change yr code by Vel Saran on January 09 2001 01:00 EST
- change yr code by mahadevan venkata on January 09 2001 02:19 EST
-
change yr code by Vel Saran on January 09 2001 01:00 EST
- change yr code by mahadevan venkata on January 09 2001 05:06 EST
-
change yr code[ Go to top ]
- Posted by: Rinku Razdan
- Posted on: January 09 2001 00:36 EST
- in response to mahadevan venkata
Change yr EmployeePK.java
replace public string EmployeeId to public string id;
Rinku
-
change yr code[ Go to top ]
- Posted by: mahadevan venkata
- Posted on: January 09 2001 05:06 EST
- in response to Rinku Razdan
hi,
i have changed it, it does not work....
can i do it without a primary key class............
thanks -
change yr code[ Go to top ]
- Posted by: Vel Saran
- Posted on: January 09 2001 13:00 EST
- in response to mahadevan venkata
Hi Mahadevan,
Please make the following changes in u'r code:
In the EmployeeBean make the ejbCreate method to return PrimaryKey.
Code u'r PrimaryKey as follows:
public class EmployeePK implements java.io.Serializable
{
public String id;
//public int id;
public int hashCode( )
{
return Integer.parseInt(id);
}
public boolean equals(Object obj)
{
if(obj instanceof EmployeePK)
{
return (id == ((EmployeePK)obj).id);
}
return false;
}
}
Hope this will do..
Regards
Saran
-
change yr code[ Go to top ]
- Posted by: mahadevan venkata
- Posted on: January 09 2001 14:19 EST
- in response to Vel Saran
hi saran,
thanks a lot, how come i forgot the concept of hashcode...
will mail you tomorrow after trying out your code........
thanks again......
good night.....(it is around 8:30 at germany)
bye
madhavan