I have simple EJB with CMP fields
it does not have ejbCreate() & ejbPostCreate() functions, but has
ejbCreate(long pk) ejbPostCreate(long pk) functions. Primary key class
in
deployment descriptor is java.lang.Long
Here is extract from class definition:

public class RoleBean implements EntityBean {
    public long roleID; //this is primary key
    public String roleName;

    public void ejbPostCreate(long roleID) throws CreateException {
    }

    public java.lang.Long ejbCreate(long roleID) throws CreateException,

DuplicateKeyException {
 this.roleID = roleID;
 roleName = "";

 // In CMP, should return null.
 return null;
    }
//.....
}

public interface RoleHome extends EJBHome {
    public Role create(long roleID) throws CreateException,
RemoteException;
    public Role findByPrimaryKey(java.lang.Long pk) throws
FinderException, RemoteException;
    public Enumeration findByName(String roleName) throws
FinderException, RemoteException;
    public Enumeration findAll() throws FinderException,
RemoteException;
}

all bean classes compile successfully & are deployed in EJB container.
My client application can successfully retreieve & update bean
information, but as soon as i try to write code to create new bean using

create(long pk) it does not compile, giving following compilation error.

RoleClient.java:57: create() in bmall.ejbs.RoleHome cannot be applied to

(long)
  Role role = home.create(1L);

and here is my client code

public class RoleClient {

    public static void main(String[] arg) {

 try {

     Properties p = new Properties();
     p.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.rmi.registry.RegistryContextFactory");
     p.put(Context.PROVIDER_URL, "rmi://localhost:1099");

     Context initialContext = new InitialContext(p);

       RoleHome home = (RoleHome) initialContext.lookup("Role");

  //following lines compile and executes with no problem updating
database record
     Role role = home.findByPrimaryKey(new Long(0L));
     role.setName("updating role name");

  //this line fails to compile with above error message
          Role role = home.create(1L);

 } catch (Exception e) {
     e.printStackTrace();
 }
}

these do not really make sence to me, but most likely i am missing
something
very important.

Thank you very much for your help

----
This list is cross-posted to two mail lists.  To unsubscribe,
follow the instructions below for the list you subscribed to.
For objectweb.org: send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe ejb-container-group".
For enhydra.org: send email to [EMAIL PROTECTED] and include
in the body of the message "unsubscribe ejb-container-group".

Reply via email to