0 Replies Latest reply on Sep 29, 2004 7:52 AM by marcfleury

    GOT IT!! I got a JBOSS + ECLIPSE + JBOSS-IDE + XDOCLET examp

    marcfleury

      Finally I could get a CMP example working on JBOSS + ECLIPSE + JBOSS-IDE + XDOCLET

      I wanted to share the example with all of you.

      package product.ejb;

      import javax.ejb.EntityBean;
      import javax.ejb.EntityContext;
      import javax.ejb.CreateException;

      import org.apache.log4j.Category;

      import javax.ejb.RemoveException;
      import javax.ejb.EJBException;
      /**
      * @ejb.bean name="Product"
      *
      * display-name="Product Bean"
      * description="Entity Bean For Product Schema"
      * jndi-name="ejb/Product"
      * type="CMP"
      * cmp-version="2.x"
      * view-type="remote"
      * primkey-field= "id"
      *
      *
      *
      * @ejb.finder
      * signature = "Product findByPrimaryKey(java.lang.Integer id)"
      * query = "Select Object(P) from Product P where P.id=?1"
      * transaction-type="NotSupported"
      *
      * @ejb.finder
      * signature="java.util.Collection findAll()"
      * query="Select Object(P) from Product P"
      * transaction-type="NotSupported"
      *
      * @jboss-query
      * signature="Product findByPrimaryKey(java.lang.Integer id)"
      * query="Select Object(P) from Product P where P.id=?1"
      *
      * @jboss-query
      * signature="Collection findAll()"
      * query="Select Object(P) from Product P"
      *
      * @ejb.persistence
      * table-name="products"
      *
      *
      *
      */
      public abstract class ProductBean implements EntityBean {

      //The entity bean lifeline
      private EntityContext ctx;

      //Tell your vows to this logger
      private Category log = Category.getInstance(getClass());

      /**
      * @throws CreateException
      * @ejb.create-method
      */
      public Integer ejbCreate(Integer id, String name, Double price)
      throws CreateException
      {

      log.info("Adding product type <" + name + "> to database");
      setId(id);
      setName(name);
      setPrice(price);
      return null;
      }

      public void ejbPostCreate(Integer id, String name, Double price)
      throws CreateException

      {

      }

      /**
      *
      * @ejb.interface-method
      * @ejb.persistence-field
      * @ejb.pk-field
      * @ejb.persistence column-name="id"
      * jdbc-type="INTEGER"
      * sql-type="INTEGER"
      */

      public abstract Integer getId();
      public abstract void setId(Integer id);


      /**
      *@ejb.interface-method
      *@ejb.persistence-field
      *@ejb.persistence column-name="name"
      * jdbc-type="VARCHAR"
      * sql-type = "VARCHAR(50)"
      */

      public abstract String getName();
      public abstract void setName(String s);

      /**
      *@ejb.interface-method
      *@ejb.persistence-field
      *@ejb.persistence column-name="price"
      * jdbc-type="DOUBLE"
      * sql-type="DOUBLE"
      */
      public abstract Double getPrice();
      public abstract void setPrice(Double price);


      public void ejbRemove() throws RemoveException, EJBException
      {
      log.info("Remove :" + getName());
      }

      public void setEntityContext(EntityContext ctx)
      {
      this.ctx = ctx;
      }

      public void unsetEntityContext()
      {
      ctx=null;
      }

      public void ejbActivate(){}

      public void ejbPassivate(){}

      public void ejbLoad(){}

      public void ejbStore(){}



      }

      Hope this will help new-bies.

      My heartful thanks to JBOSS development team.