5 Replies Latest reply on Jun 9, 2008 12:54 AM by mallikarjun_nbsg

    remove method functionality in CMP Bean

      Hi,

      I would need code for remove method functionality in CMP Bean. I am using EJB 2.0.

      1. What is the return type of remove method when calling from session bean.
      2. when passing the primary key in remove method to remove the record from the table. how should the query to be written in the ejb-jar.xml

      Please send me all these details.

      Thank you,
      Mallikarjun.

        • 1. Re: remove method functionality in CMP Bean
          itsme

          Hi,

          I think you are looking for

          public void ejbRemove()

          for CMP Entity Beans in EJB2.x style. While you are calling the reove method on the entity bean itself, there is no need to pass in a identifier.

          When calling remove via a session facade you can either first call findByPrimaryKey(id) and then call remove on that bean (has all of its ejb overhead while loading the entity from database just to remove it) or you delete it by sending an sql string right to the database direct from session facade (what prevents you from loading the entity). Then this method is a facade method that needs to be declared on the (Local/Remote) Interface of the session facade.

          Hope this helps
          \sandor\

          • 2. Re: remove method functionality in CMP Bean

            Hi,

            My scenario is to delete a record from the table.

            I am using client and calling session facade, from session facade calling CMP Home Interface remove method by passing "primary key" value. Bean ejbRemove method is also having the same "primary key" parameter. In the method body, do I need to call set method of that primary key? do I need to write any query for this method in the ejb-jar.xml

            Please help me out.

            Thank you,
            Mallikarjun.


            • 3. Re: remove method functionality in CMP Bean

              hi,

              can any body help on the below scenario please.

              Thank you,
              Mallikarjun.

              • 4. Re: remove method functionality in CMP Bean

                Hi,

                My scenario is to delete a record from the table.

                I am using client and calling session facade, from session facade calling CMP Home Interface remove method by passing "primary key" value. Bean ejbRemove method is also having the same "primary key" parameter. In the method body, do I need to call set method of that primary key? do I need to write any query for this method in the ejb-jar.xml

                Please help me out.

                Thank you,
                Mallikarjun.

                • 5. Re: remove method functionality in CMP Bean


                  when trying to remove a record from the DB. I am using findByPrimaryKey(id) method and then calling home.remove method, but while deployment I am getting the following error. Please help me out to remove the record from DB.


                  10:01:14,271 WARN [verifier] EJB spec violation:
                  Bean : RCVlanHome
                  Method : public abstract void remove() throws RemoveException, EJBException
                  Section: 12.2.11
                  Warning: Each local home method must match a method defined in the entity bean class.

                  10:01:14,302 ERROR [MainDeployer] could not create deployment: file:/C:/jboss-4.0.2/server/default/deploy/sasemsProj.jar
                  org.jboss.deployment.DeploymentException: Verification of Enterprise Beans failed, see above for error messages.
                  at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:553)
                  at org.jboss.deployment.MainDeployer.create(MainDeployer.java:918)
                  at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:774)
                  at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
                  at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:585)