3 Replies Latest reply on Nov 3, 2003 3:15 AM by didi1976

    unable to update table through CMP

    srikanth.d

      Hi,
      I am new to EJBs,I am using jboss 3.2.1 .i am sucessfully insert the rows thorough CMP.but i am unable to update the rows in table through CMP.

      What are the changes we required to jbosscmp-jdbc.xml,ejb-jar.xml for updating tables.

      Please mail me.
      Thank you,

      Regards,
      Sathish

        • 1. Re: unable to update table through CMP
          dries.demoor

          Hello,

          I don't think you have to change something in the jbosscmp-jdbc.xml

          Just lookup the bean you want to change using a CMP
          findermethod and call the setxxx(new Value) method on it. This will do the job.


          Regards,

          Dries

          • 2. Re: unable to update table through CMP
            srikanth.d

            thank you,
            but my requirement is update table_name set empname=3 where emp-id=2
            emp-id is primary key.
            please explain in detail
            Regards,
            Sathish

            • 3. Re: unable to update table through CMP
              didi1976

              Hi,

              lets assume you have an bean called "Emp". You are using it locally on the server (otherwise you have to narrow the Object). The Bean is bound in the JNDI to "ejb/local/EmpBean". The primary key is of type java.lang.Long. So it could look like:

              InitialContext ctx = new InitialContext();
              EmpHome empHome = (EmpHome)ctx.lookup("ejb/local/EmpBean");
              Emp emp = empHome.findByPrimaryKey(new Long(2));
              emp.setName("3");

              Regards,
              Didi