how to invoke the ejbRemove method so i can remove record

Discussions

EJB design: how to invoke the ejbRemove method so i can remove record

  1. hello freind,

    i am writing my ejbremove in bean as follows

    public void ejbRemove()
    {
    }

    now i want to delete the record from database .
    how to invoke that method and as any code to be written in ejbremove. i am using CMP for entity bean.

    client:
    InitialContext ic = new InitialContext();
    Object o = ic.lookup("myjndi");
    emp.EmplHome h = (emp.EmplHome) o;

    from here how to remove the record by invoking ejbRemove method in bean . please suggest me..

    with regards
    k.ramakrishna
  2. Could U please..Send the info in detail 2 my mail..rvanil@haridassoftech.com

    Thanx,
    Anil
  3. You must do a casting(to the ejb class) like this:

    ...
    emp.EmplHome h = (emp.EmplHome) o;
    emp.Empl myEmpl = (emp.Empl)
    h.findByPrimaryKey(primaryKey);

    With myEmpl references the registry of DB that you wish. With myEmpl call all methods of remote interface and ejbRemove()....
    (emp.Empl is the class for implementation of the ejb)

    my e-mail: rabaiag at latinmail dot com

    Note: Sorry, my english is not very well. I speak spanish.


  4. Get a reference to the primary key as follows and then call the remove on the home interface

    BeanPK bPK= (BeanPK) Bean.getPrimaryKey();
    BeanHome.remove(pPK);