1 Reply Latest reply on Apr 15, 2005 10:22 AM by Fernando Fernandes

    Can you please give me a sample Entity Bean Source code to d

    bm merugu Newbie

      I am trying to deploy one sample Entity bean in the JBOSS server but not able to configure it I tried to use the Bank application but not able to do it.
      Can any one please let me know any sample source code and the steps to deploy and access it.

      Thanks

        • 1. Re: Can you please give me a sample Entity Bean Source code
          Fernando Fernandes Newbie

          Ok, I'll send you an example of a CMP-EJB Produto. It uses the HyperSonic JBoss-native database.

          Bean class:
          --------------------------------------------------------------------------
          package br.cefetrn.leilao.beans;

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

          /**
          <!-- begin-lomboz-definition -->
          <?xml version="1.0" encoding="UTF-8"?>
          <lomboz:EJB xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:lomboz="http://lomboz.objectlearn.com/xml/lomboz">
          <lomboz:entity>
          <lomboz:entityEjb>
          <j2ee:display-name>Produto</j2ee:display-name>
          <j2ee:ejb-name>Produto</j2ee:ejb-name>
          <j2ee:ejb-class>br.cefetrn.leilao.beans.ProdutoBean</j2ee:ejb-class>
          <j2ee:persistence-type>Container</j2ee:persistence-type>
          <j2ee:prim-key-class>java.lang.Integer</j2ee:prim-key-class>
          <j2ee:cmp-version>2.x</j2ee:cmp-version>
          <j2ee:abstract-schema-name>schProduto</j2ee:abstract-schema-name>
          <j2ee:primkey-field>codigo</j2ee:primkey-field>
          </lomboz:entityEjb>

          <lomboz:fieldMappings>
          <lomboz:fieldName>codigo</lomboz:fieldName>
          <lomboz:fieldType>java.lang.Integer</lomboz:fieldType>
          <lomboz:columnName>CODIGO</lomboz:columnName>
          <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
          <lomboz:sqlType>INTEGER</lomboz:sqlType>
          <lomboz:readOnly>false</lomboz:readOnly>
          <lomboz:primaryKey>true</lomboz:primaryKey>
          </lomboz:fieldMappings>

          <lomboz:fieldMappings>
          <lomboz:fieldName>codusuario</lomboz:fieldName>
          <lomboz:fieldType>java.lang.Integer</lomboz:fieldType>
          <lomboz:columnName>CODUSUARIO</lomboz:columnName>
          <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
          <lomboz:sqlType>INTEGER</lomboz:sqlType>
          <lomboz:readOnly>false</lomboz:readOnly>
          <lomboz:primaryKey>false</lomboz:primaryKey>
          </lomboz:fieldMappings>

          <lomboz:fieldMappings>
          <lomboz:fieldName>codcategoria</lomboz:fieldName>
          <lomboz:fieldType>java.lang.Integer</lomboz:fieldType>
          <lomboz:columnName>CODCATEGORIA</lomboz:columnName>
          <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
          <lomboz:sqlType>INTEGER</lomboz:sqlType>
          <lomboz:readOnly>false</lomboz:readOnly>
          <lomboz:primaryKey>false</lomboz:primaryKey>
          </lomboz:fieldMappings>

          <lomboz:fieldMappings>
          <lomboz:fieldName>codsituacao</lomboz:fieldName>
          <lomboz:fieldType>java.lang.Integer</lomboz:fieldType>
          <lomboz:columnName>CODSITUACAO</lomboz:columnName>
          <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
          <lomboz:sqlType>INTEGER</lomboz:sqlType>
          <lomboz:readOnly>false</lomboz:readOnly>
          <lomboz:primaryKey>false</lomboz:primaryKey>
          </lomboz:fieldMappings>

          <lomboz:fieldMappings>
          <lomboz:fieldName>produto</lomboz:fieldName>
          <lomboz:fieldType>java.lang.String</lomboz:fieldType>
          <lomboz:columnName>PRODUTO</lomboz:columnName>
          <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
          <lomboz:sqlType>VARCHAR</lomboz:sqlType>
          <lomboz:readOnly>false</lomboz:readOnly>
          <lomboz:primaryKey>false</lomboz:primaryKey>
          </lomboz:fieldMappings>

          <lomboz:fieldMappings>
          <lomboz:fieldName>descricao</lomboz:fieldName>
          <lomboz:fieldType>java.lang.String</lomboz:fieldType>
          <lomboz:columnName>DESCRICAO</lomboz:columnName>
          <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
          <lomboz:sqlType>VARCHAR</lomboz:sqlType>
          <lomboz:readOnly>false</lomboz:readOnly>
          <lomboz:primaryKey>false</lomboz:primaryKey>
          </lomboz:fieldMappings>

          <lomboz:fieldMappings>
          <lomboz:fieldName>lancemin</lomboz:fieldName>
          <lomboz:fieldType>java.lang.Double</lomboz:fieldType>
          <lomboz:columnName>LANCEMIN</lomboz:columnName>
          <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
          <lomboz:sqlType>MONEY</lomboz:sqlType>
          <lomboz:readOnly>false</lomboz:readOnly>
          <lomboz:primaryKey>false</lomboz:primaryKey>
          </lomboz:fieldMappings>

          <lomboz:fieldMappings>
          <lomboz:fieldName>datainicial</lomboz:fieldName>
          <lomboz:fieldType>java.util.Date</lomboz:fieldType>
          <lomboz:columnName>DATAINI</lomboz:columnName>
          <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
          <lomboz:sqlType>DATE</lomboz:sqlType>
          <lomboz:readOnly>false</lomboz:readOnly>
          <lomboz:primaryKey>false</lomboz:primaryKey>
          </lomboz:fieldMappings>

          <lomboz:fieldMappings>
          <lomboz:fieldName>datafinal</lomboz:fieldName>
          <lomboz:fieldType>java.util.Date</lomboz:fieldType>
          <lomboz:columnName>DATAFIM</lomboz:columnName>
          <lomboz:jdbcType>VARCHAR</lomboz:jdbcType>
          <lomboz:sqlType>DATE</lomboz:sqlType>
          <lomboz:readOnly>false</lomboz:readOnly>
          <lomboz:primaryKey>false</lomboz:primaryKey>
          </lomboz:fieldMappings>

          <lomboz:tableName>Produto</lomboz:tableName>
          <lomboz:dataSourceName></lomboz:dataSourceName>
          </lomboz:entity>
          </lomboz:EJB>
          <!-- end-lomboz-definition -->
          *
          *
          *
          * @ejb.bean name="Produto"
          * jndi-name="ProdutoBean"
          * type="CMP"
          * primkey-field="codigo"
          * schema="schProduto"
          * cmp-version="2.x"
          *
          *
          * @ejb.persistence
          * table-name="Produto"
          *
          * @ejb.finder
          * query="SELECT OBJECT(a) FROM schProduto as a WHERE (a.codSituacao = 1)"
          * signature="java.util.Collection findAll()"
          *
          * @ejb.finder
          * query="SELECT OBJECT(a) FROM schProduto as a WHERE (a.codUsuario=?1) AND (a.codSituacao = 1)"
          * signature="java.util.Collection findProdutosByUserID(java.lang.Integer codigousuario)"
          *
          * @ejb.finder
          * query="SELECT OBJECT(a) FROM schProduto as a WHERE (a.codCategoria=?1) AND (a.codSituacao = 1)"
          * signature="java.util.Collection findProdutosByCategoria(java.lang.Integer codcategoria)"
          *
          *
          **/

          public abstract class ProdutoBean implements EntityBean {
          protected EntityContext eContext;

          public static final Integer SITUA_ANDAMENTO = new Integer(1);
          public static final Integer SITUA_FINALIZADO = new Integer(2);

          /**
          * The ejbCreate method.
          * @ejb.create-method
          */
          public java.lang.Integer ejbCreate(java.lang.Integer codigo,
          java.lang.Integer codusuario,
          java.lang.Integer codcategoria,
          java.lang.Integer codsituacao,
          java.lang.String produto,
          java.lang.String descricao,
          java.lang.Double lancemin,
          java.util.Date datainicial,
          java.util.Date datafinal) throws javax.ejb.CreateException {
          this.setCodigo(codigo);
          this.setCodUsuario(codusuario);
          this.setCodCategoria(codcategoria);
          this.setCodSituacao(codsituacao);
          this.setProduto(produto);
          this.setDescricao(descricao);
          this.setLancemin(lancemin);

          return null;
          }

          /**
          * The container invokes this method immediately after it calls ejbCreate.
          *
          */
          public void ejbPostCreate() throws javax.ejb.CreateException {
          }

          /**
          * Returns the codigo
          * @return the codigo
          *
          * @ejb.persistent-field
          * @ejb.persistence
          * column-name="CODIGO"
          * sql-type="INTEGER"
          * @ejb.pk-field
          * @ejb.interface-method
          *
          */
          public abstract java.lang.Integer getCodigo();

          /**
          * Sets the codigo
          *
          * @param java.lang.Integer the new codusuario value
          *
          * @ejb.interface-method
          */
          public abstract void setCodigo(java.lang.Integer codigo);

          /**
          * Returns the codusuario
          * @return the codusuario
          *
          * @ejb.persistent-field
          * @ejb.persistence
          * column-name="CODUSUARIO"
          * sql-type="INTEGER"
          * @ejb.interface-method
          *
          */
          public abstract java.lang.Integer getCodUsuario();

          /**
          * Sets the codusuario
          *
          * @param java.lang.Integer the new codigo value
          *
          * @ejb.interface-method
          */
          public abstract void setCodUsuario(java.lang.Integer codigo);

          /**
          * Returns the codcategoria
          * @return the codcategoria
          *
          * @ejb.persistent-field
          * @ejb.persistence
          * column-name="CODCATEGORIA"
          * sql-type="INTEGER"
          * @ejb.interface-method
          *
          */
          public abstract java.lang.Integer getCodCategoria();

          /**
          * Sets the codcategoria
          *
          * @param java.lang.Integer the new codigo value
          *
          * @ejb.interface-method
          */
          public abstract void setCodCategoria(java.lang.Integer codigo);

          /**
          * Returns the codsituacao
          * @return the codsituacao
          *
          * @ejb.persistent-field
          * @ejb.persistence
          * column-name="CODSITUACAO"
          * sql-type="INTEGER"
          * @ejb.interface-method
          *
          */
          public abstract java.lang.Integer getCodSituacao();

          /**
          * Sets the codsituacao
          *
          * @param java.lang.Integer the new codsituacao value
          *
          * @ejb.interface-method
          */
          public abstract void setCodSituacao(java.lang.Integer codsituacao);

          /**
          * Returns the produto
          * @return the produto
          *
          * @ejb.persistent-field
          * @ejb.persistence
          * column-name="PRODUTO"
          * sql-type="VARCHAR"
          *
          * @ejb.interface-method
          *
          */
          public abstract java.lang.String getProduto();

          /**
          * Sets the descricao
          *
          * @param java.lang.String the new descricao value
          *
          * @ejb.interface-method
          */
          public abstract void setProduto(java.lang.String produto);

          /**
          * Returns the descricao
          * @return the descricao
          *
          * @ejb.persistent-field
          * @ejb.persistence
          * column-name="DESCRICAO"
          * sql-type="VARCHAR"
          *
          * @ejb.interface-method
          *
          */
          public abstract java.lang.String getDescricao();

          /**
          * Sets the descricao
          *
          * @param java.lang.String the new descricao value
          *
          * @ejb.interface-method
          */
          public abstract void setDescricao(java.lang.String descricao);

          /**
          * Returns the lancemin
          * @return the lancemin
          *
          * @ejb.persistent-field
          * @ejb.persistence
          * column-name="LANCEMIN"
          * sql-type="MONEY"
          *
          * @ejb.interface-method
          *
          */
          public abstract java.lang.Double getLancemin();

          /**
          * Sets the lancemin
          *
          * @param java.lang.Double the new lancemin value
          *
          * @ejb.interface-method
          */
          public abstract void setLancemin(java.lang.Double lancemin);

          /**
          * Returns the datainicial
          * @return the datainicial
          *
          * @ejb.persistent-field
          * @ejb.persistence
          * column-name="DATAINI"
          * sql-type="DATE"
          *
          * @ejb.interface-method
          *
          */
          public abstract java.util.Date getDatainicial();

          /**
          * Sets the datainicial
          *
          * @param java.util.Date the new datainicial value
          *
          * @ejb.interface-method
          */
          public abstract void setDatainicial(java.util.Date datainicial);

          /**
          * Returns the datafinal
          * @return the datafinal
          *
          * @ejb.persistent-field
          * @ejb.persistence
          * column-name="DATAFIM"
          * sql-type="DATE"
          *
          * @ejb.interface-method
          *
          */
          public abstract java.util.Date getDatafinal();

          /**
          * Sets the datafinal
          *
          * @param java.util.Date the new datafinal value
          *
          * @ejb.interface-method
          */
          public abstract void setDatafinal(java.util.Date datafinal);

          /**
          * @ejb.interface-method
          * view-type="remote"
          **/
          public ProdutoData getProdutoData(){
          return new ProdutoData(getCodigo(),
          getCodUsuario(),
          getCodCategoria(),
          getCodSituacao(),
          getProduto(),
          getDescricao(),
          getLancemin(),
          getDatainicial(),
          getDatafinal());
          }
          /**
          * @param context
          */
          public void setEntityContext(EntityContext context) {
          this.eContext = context;
          }

          public void unsetEntityContext(EntityContext context) {
          this.eContext = null;
          }
          }

          Bean's Home Interface:
          --------------------------------------------------------------------------
          package br.cefetrn.leilao.beans;

          /**
          * Interface Home para Produto.
          * @lomboz generated
          */
          public interface ProdutoHome
          extends javax.ejb.EJBHome
          {
          public static final String COMP_NAME="java:comp/env/ejb/Produto";
          public static final String JNDI_NAME="ProdutoBean";

          public br.cefetrn.leilao.beans.Produto create(java.lang.Integer codigo , java.lang.Integer codusuario , java.lang.Integer codcategoria , java.lang.Integer codsituacao , java.lang.String produto , java.lang.String descricao , java.lang.Double lancemin , java.util.Date datainicial , java.util.Date datafinal)
          throws javax.ejb.CreateException,java.rmi.RemoteException;

          public java.util.Collection findAll()
          throws javax.ejb.FinderException,java.rmi.RemoteException;

          public java.util.Collection findProdutosByUserID(java.lang.Integer codigousuario)
          throws javax.ejb.FinderException,java.rmi.RemoteException;

          public java.util.Collection findProdutosByCategoria(java.lang.Integer codcategoria)
          throws javax.ejb.FinderException,java.rmi.RemoteException;

          public br.cefetrn.leilao.beans.Produto findByPrimaryKey(java.lang.Integer pk)
          throws javax.ejb.FinderException,java.rmi.RemoteException;

          }

          Bean's Remote Interface:
          --------------------------------------------------------------------------
          package br.cefetrn.leilao.beans;

          /**
          * Interface Remota para Produto.
          * @lomboz generated
          */
          public interface Produto
          extends javax.ejb.EJBObject
          {
          /**
          * Returns the codigo
          * @return the codigo
          */
          public java.lang.Integer getCodigo( )
          throws java.rmi.RemoteException;

          /**
          * Sets the codigo
          * @param java.lang.Integer the new codusuario value
          */
          public void setCodigo( java.lang.Integer codigo )
          throws java.rmi.RemoteException;

          /**
          * Returns the codusuario
          * @return the codusuario
          */
          public java.lang.Integer getCodUsuario( )
          throws java.rmi.RemoteException;

          /**
          * Sets the codusuario
          * @param java.lang.Integer the new codigo value
          */
          public void setCodUsuario( java.lang.Integer codigo )
          throws java.rmi.RemoteException;

          /**
          * Returns the codcategoria
          * @return the codcategoria
          */
          public java.lang.Integer getCodCategoria( )
          throws java.rmi.RemoteException;

          /**
          * Sets the codcategoria
          * @param java.lang.Integer the new codigo value
          */
          public void setCodCategoria( java.lang.Integer codigo )
          throws java.rmi.RemoteException;

          /**
          * Returns the codsituacao
          * @return the codsituacao
          */
          public java.lang.Integer getCodSituacao( )
          throws java.rmi.RemoteException;

          /**
          * Sets the codsituacao
          * @param java.lang.Integer the new codsituacao value
          */
          public void setCodSituacao( java.lang.Integer codsituacao )
          throws java.rmi.RemoteException;

          /**
          * Returns the produto
          * @return the produto
          */
          public java.lang.String getProduto( )
          throws java.rmi.RemoteException;

          /**
          * Sets the descricao
          * @param java.lang.String the new descricao value
          */
          public void setProduto( java.lang.String produto )
          throws java.rmi.RemoteException;

          /**
          * Returns the descricao
          * @return the descricao
          */
          public java.lang.String getDescricao( )
          throws java.rmi.RemoteException;

          /**
          * Sets the descricao
          * @param java.lang.String the new descricao value
          */
          public void setDescricao( java.lang.String descricao )
          throws java.rmi.RemoteException;

          /**
          * Returns the lancemin
          * @return the lancemin
          */
          public java.lang.Double getLancemin( )
          throws java.rmi.RemoteException;

          /**
          * Sets the lancemin
          * @param java.lang.Double the new lancemin value
          */
          public void setLancemin( java.lang.Double lancemin )
          throws java.rmi.RemoteException;

          /**
          * Returns the datainicial
          * @return the datainicial
          */
          public java.util.Date getDatainicial( )
          throws java.rmi.RemoteException;

          /**
          * Sets the datainicial
          * @param java.util.Date the new datainicial value
          */
          public void setDatainicial( java.util.Date datainicial )
          throws java.rmi.RemoteException;

          /**
          * Returns the datafinal
          * @return the datafinal
          */
          public java.util.Date getDatafinal( )
          throws java.rmi.RemoteException;

          /**
          * Sets the datafinal
          * @param java.util.Date the new datafinal value
          */
          public void setDatafinal( java.util.Date datafinal )
          throws java.rmi.RemoteException;

          public br.cefetrn.leilao.beans.ProdutoData getProdutoData( )
          throws java.rmi.RemoteException;

          }

          CMP-EJB class:
          --------------------------------------------------------------------------

          package br.cefetrn.leilao.beans;

          /**
          * Camada CMP para Produto.
          * @lomboz generated
          */
          public abstract class ProdutoCMP
          extends br.cefetrn.leilao.beans.ProdutoBean
          implements javax.ejb.EntityBean
          {

          /**
          * ejbPostCreate gerado para o método ejbCreate correspondente.
          *
          * @see #ejbCreate(java.lang.Integer codigo,java.lang.Integer codusuario,java.lang.Integer codcategoria,java.lang.Integer codsituacao,java.lang.String produto,java.lang.String descricao,java.lang.Double lancemin,java.util.Date datainicial,java.util.Date datafinal)
          */
          public void ejbPostCreate(java.lang.Integer codigo,java.lang.Integer codusuario,java.lang.Integer codcategoria,java.lang.Integer codsituacao,java.lang.String produto,java.lang.String descricao,java.lang.Double lancemin,java.util.Date datainicial,java.util.Date datafinal)
          {
          }

          public void ejbLoad()
          {
          }

          public void ejbStore()
          {
          }

          public void ejbActivate()
          {
          }

          public void ejbPassivate()
          {

          }

          public void setEntityContext(javax.ejb.EntityContext ctx)
          {
          super.setEntityContext(ctx);
          }

          public void unsetEntityContext()
          {
          }

          public void ejbRemove() throws javax.ejb.RemoveException
          {

          }

          /* Value Objects BEGIN */

          /* Value Objects END */

          public abstract java.lang.Integer getCodigo() ;

          public abstract void setCodigo( java.lang.Integer codigo ) ;

          public abstract java.lang.Integer getCodUsuario() ;

          public abstract void setCodUsuario( java.lang.Integer codUsuario ) ;

          public abstract java.lang.Integer getCodCategoria() ;

          public abstract void setCodCategoria( java.lang.Integer codCategoria ) ;

          public abstract java.lang.Integer getCodSituacao() ;

          public abstract void setCodSituacao( java.lang.Integer codSituacao ) ;

          public abstract java.lang.String getProduto() ;

          public abstract void setProduto( java.lang.String produto ) ;

          public abstract java.lang.String getDescricao() ;

          public abstract void setDescricao( java.lang.String descricao ) ;

          public abstract java.lang.Double getLancemin() ;

          public abstract void setLancemin( java.lang.Double lancemin ) ;

          public abstract java.util.Date getDatainicial() ;

          public abstract void setDatainicial( java.util.Date datainicial ) ;

          public abstract java.util.Date getDatafinal() ;

          public abstract void setDatafinal( java.util.Date datafinal ) ;

          }

          Bean's Value Object:
          --------------------------------------------------------------------------
          package br.cefetrn.leilao.beans;

          import java.rmi.RemoteException;

          import javax.ejb.FinderException;
          import javax.naming.NamingException;

          /**
          * Data Object para Produto.
          * @lomboz generated
          */
          public class ProdutoData
          extends java.lang.Object
          implements java.io.Serializable
          {
          private java.lang.Integer codigo;
          private java.lang.Integer codUsuario;
          private java.lang.Integer codCategoria;
          private java.lang.Integer codSituacao;
          private java.lang.String produto;
          private java.lang.String descricao;
          private java.lang.Double lancemin;
          private java.util.Date datainicial;
          private java.util.Date datafinal;

          /* begin value object */

          /* INICIO -- Métodos especializados */

          public UsuarioData getUsuario() {
          Usuario usuario = null;
          UsuarioData usuariodata = null;
          try {
          usuario = UsuarioUtil.getHome().findByPrimaryKey(this.codUsuario);
          usuariodata = usuario.getUsuarioData();
          } catch (RemoteException rex) {
          } catch (FinderException fex) {
          } catch (NamingException nex) {
          }
          return usuariodata;
          }

          public CategoriaData getCategoria() {
          Categoria categoria = null;
          CategoriaData categoriadata = null;
          try {
          categoria = CategoriaUtil.getHome().findByPrimaryKey(this.codCategoria);
          categoriadata = categoria.getCategoriaData();
          } catch (RemoteException rex) {
          } catch (FinderException fex) {
          } catch (NamingException nex) {
          }
          return categoriadata;
          }

          public java.lang.String getSituacao() {
          if (this.codSituacao.compareTo(ProdutoBean.SITUA_ANDAMENTO) == 0) {
          return "Em andamento";
          } else if (this.codSituacao.compareTo(ProdutoBean.SITUA_FINALIZADO) == 0) {
          return "Finalizado";
          }
          return "";
          }

          /* FIM -- Métodos especializados */


          /* end value object */

          public ProdutoData()
          {
          }

          public ProdutoData( java.lang.Integer codigo,java.lang.Integer codUsuario,java.lang.Integer codCategoria,java.lang.Integer codSituacao,java.lang.String produto,java.lang.String descricao,java.lang.Double lancemin,java.util.Date datainicial,java.util.Date datafinal )
          {
          setCodigo(codigo);
          setCodUsuario(codUsuario);
          setCodCategoria(codCategoria);
          setCodSituacao(codSituacao);
          setProduto(produto);
          setDescricao(descricao);
          setLancemin(lancemin);
          setDatainicial(datainicial);
          setDatafinal(datafinal);
          }

          public ProdutoData( ProdutoData otherData )
          {
          setCodigo(otherData.getCodigo());
          setCodUsuario(otherData.getCodUsuario());
          setCodCategoria(otherData.getCodCategoria());
          setCodSituacao(otherData.getCodSituacao());
          setProduto(otherData.getProduto());
          setDescricao(otherData.getDescricao());
          setLancemin(otherData.getLancemin());
          setDatainicial(otherData.getDatainicial());
          setDatafinal(otherData.getDatafinal());

          }

          public java.lang.Integer getPrimaryKey() {
          return getCodigo();
          }

          public java.lang.Integer getCodigo()
          {
          return this.codigo;
          }
          public void setCodigo( java.lang.Integer codigo )
          {
          this.codigo = codigo;
          }

          public java.lang.Integer getCodUsuario()
          {
          return this.codUsuario;
          }
          public void setCodUsuario( java.lang.Integer codUsuario )
          {
          this.codUsuario = codUsuario;
          }

          public java.lang.Integer getCodCategoria()
          {
          return this.codCategoria;
          }
          public void setCodCategoria( java.lang.Integer codCategoria )
          {
          this.codCategoria = codCategoria;
          }

          public java.lang.Integer getCodSituacao()
          {
          return this.codSituacao;
          }
          public void setCodSituacao( java.lang.Integer codSituacao )
          {
          this.codSituacao = codSituacao;
          }

          public java.lang.String getProduto()
          {
          return this.produto;
          }
          public void setProduto( java.lang.String produto )
          {
          this.produto = produto;
          }

          public java.lang.String getDescricao()
          {
          return this.descricao;
          }
          public void setDescricao( java.lang.String descricao )
          {
          this.descricao = descricao;
          }

          public java.lang.Double getLancemin()
          {
          return this.lancemin;
          }
          public void setLancemin( java.lang.Double lancemin )
          {
          this.lancemin = lancemin;
          }

          public java.util.Date getDatainicial()
          {
          return this.datainicial;
          }
          public void setDatainicial( java.util.Date datainicial )
          {
          this.datainicial = datainicial;
          }

          public java.util.Date getDatafinal()
          {
          return this.datafinal;
          }
          public void setDatafinal( java.util.Date datafinal )
          {
          this.datafinal = datafinal;
          }

          public String toString()
          {
          StringBuffer str = new StringBuffer("{");

          str.append("codigo=" + getCodigo() + " " + "codUsuario=" + getCodUsuario() + " " + "codCategoria=" + getCodCategoria() + " " + "codSituacao=" + getCodSituacao() + " " + "produto=" + getProduto() + " " + "descricao=" + getDescricao() + " " + "lancemin=" + getLancemin() + " " + "datainicial=" + getDatainicial() + " " + "datafinal=" + getDatafinal());
          str.append('}');

          return(str.toString());
          }

          public boolean equals( Object pOther )
          {
          if( pOther instanceof ProdutoData )
          {
          ProdutoData lTest = (ProdutoData) pOther;
          boolean lEquals = true;

          if( this.codigo == null )
          {
          lEquals = lEquals && ( lTest.codigo == null );
          }
          else
          {
          lEquals = lEquals && this.codigo.equals( lTest.codigo );
          }
          if( this.codUsuario == null )
          {
          lEquals = lEquals && ( lTest.codUsuario == null );
          }
          else
          {
          lEquals = lEquals && this.codUsuario.equals( lTest.codUsuario );
          }
          if( this.codCategoria == null )
          {
          lEquals = lEquals && ( lTest.codCategoria == null );
          }
          else
          {
          lEquals = lEquals && this.codCategoria.equals( lTest.codCategoria );
          }
          if( this.codSituacao == null )
          {
          lEquals = lEquals && ( lTest.codSituacao == null );
          }
          else
          {
          lEquals = lEquals && this.codSituacao.equals( lTest.codSituacao );
          }
          if( this.produto == null )
          {
          lEquals = lEquals && ( lTest.produto == null );
          }
          else
          {
          lEquals = lEquals && this.produto.equals( lTest.produto );
          }
          if( this.descricao == null )
          {
          lEquals = lEquals && ( lTest.descricao == null );
          }
          else
          {
          lEquals = lEquals && this.descricao.equals( lTest.descricao );
          }
          if( this.lancemin == null )
          {
          lEquals = lEquals && ( lTest.lancemin == null );
          }
          else
          {
          lEquals = lEquals && this.lancemin.equals( lTest.lancemin );
          }
          if( this.datainicial == null )
          {
          lEquals = lEquals && ( lTest.datainicial == null );
          }
          else
          {
          lEquals = lEquals && this.datainicial.equals( lTest.datainicial );
          }
          if( this.datafinal == null )
          {
          lEquals = lEquals && ( lTest.datafinal == null );
          }
          else
          {
          lEquals = lEquals && this.datafinal.equals( lTest.datafinal );
          }

          return lEquals;
          }
          else
          {
          return false;
          }
          }

          public int hashCode()
          {
          int result = 17;

          result = 37*result + ((this.codigo != null) ? this.codigo.hashCode() : 0);

          result = 37*result + ((this.codUsuario != null) ? this.codUsuario.hashCode() : 0);

          result = 37*result + ((this.codCategoria != null) ? this.codCategoria.hashCode() : 0);

          result = 37*result + ((this.codSituacao != null) ? this.codSituacao.hashCode() : 0);

          result = 37*result + ((this.produto != null) ? this.produto.hashCode() : 0);

          result = 37*result + ((this.descricao != null) ? this.descricao.hashCode() : 0);

          result = 37*result + ((this.lancemin != null) ? this.lancemin.hashCode() : 0);

          result = 37*result + ((this.datainicial != null) ? this.datainicial.hashCode() : 0);

          result = 37*result + ((this.datafinal != null) ? this.datafinal.hashCode() : 0);

          return result;
          }

          }

          Now, you have all bean classes you'll need, and we'll pass the descriptor files below.

          JBoss XML Descriptor file (jboss.xml)
          --------------------------------------------------------------------------
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">



          <unauthenticated-principal>nobody</unauthenticated-principal>

          <enterprise-beans>


          <ejb-name>Produto</ejb-name>
          <jndi-name>ProdutoBean</jndi-name>
          <local-jndi-name>ProdutoLocal</local-jndi-name>


          </enterprise-beans>

          <resource-managers>
          </resource-managers>



          EJB-JAR XML Descriptor file (ejb-jar.xml):
          --------------------------------------------------------------------------
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

          <ejb-jar >

          <![CDATA[Sem Descrição.]]>
          <display-name>Gerado pelo XDoclet</display-name>

          <enterprise-beans>
          <!-- Session Beans -->

          <!-- Entity Beans -->


          <![CDATA[<!-- begin-lomboz-definition --> <?xml version="1.0" encoding="UTF-8"?> <lomboz:EJB xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:lomboz="http://lomboz.objectlearn.com/xml/lomboz"> <lomboz:entity> <lomboz:entityEjb> <j2ee:display-name>Produto</j2ee:display-name> <j2ee:ejb-name>Produto</j2ee:ejb-name> <j2ee:ejb-class>br.cefetrn.leilao.beans.ProdutoBean</j2ee:ejb-class> <j2ee:persistence-type>Container</j2ee:persistence-type> <j2ee:prim-key-class>java.lang.Integer</j2ee:prim-key-class> <j2ee:cmp-version>2.x</j2ee:cmp-version> <j2ee:abstract-schema-name>schProduto</j2ee:abstract-schema-name> <j2ee:primkey-field>codigo</j2ee:primkey-field> </lomboz:entityEjb> <lomboz:fieldMappings> <lomboz:fieldName>codigo</lomboz:fieldName> <lomboz:fieldType>java.lang.Integer</lomboz:fieldType> <lomboz:columnName>CODIGO</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>INTEGER</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>true</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:fieldMappings> <lomboz:fieldName>codusuario</lomboz:fieldName> <lomboz:fieldType>java.lang.Integer</lomboz:fieldType> <lomboz:columnName>CODUSUARIO</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>INTEGER</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>false</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:fieldMappings> <lomboz:fieldName>codcategoria</lomboz:fieldName> <lomboz:fieldType>java.lang.Integer</lomboz:fieldType> <lomboz:columnName>CODCATEGORIA</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>INTEGER</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>false</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:fieldMappings> <lomboz:fieldName>codsituacao</lomboz:fieldName> <lomboz:fieldType>java.lang.Integer</lomboz:fieldType> <lomboz:columnName>CODSITUACAO</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>INTEGER</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>false</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:fieldMappings> <lomboz:fieldName>produto</lomboz:fieldName> <lomboz:fieldType>java.lang.String</lomboz:fieldType> <lomboz:columnName>PRODUTO</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>VARCHAR</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>false</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:fieldMappings> <lomboz:fieldName>descricao</lomboz:fieldName> <lomboz:fieldType>java.lang.String</lomboz:fieldType> <lomboz:columnName>DESCRICAO</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>VARCHAR</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>false</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:fieldMappings> <lomboz:fieldName>lancemin</lomboz:fieldName> <lomboz:fieldType>java.lang.Double</lomboz:fieldType> <lomboz:columnName>LANCEMIN</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>MONEY</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>false</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:fieldMappings> <lomboz:fieldName>datainicial</lomboz:fieldName> <lomboz:fieldType>java.util.Date</lomboz:fieldType> <lomboz:columnName>DATAINI</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>DATE</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>false</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:fieldMappings> <lomboz:fieldName>datafinal</lomboz:fieldName> <lomboz:fieldType>java.util.Date</lomboz:fieldType> <lomboz:columnName>DATAFIM</lomboz:columnName> <lomboz:jdbcType>VARCHAR</lomboz:jdbcType> <lomboz:sqlType>DATE</lomboz:sqlType> <lomboz:readOnly>false</lomboz:readOnly> <lomboz:primaryKey>false</lomboz:primaryKey> </lomboz:fieldMappings> <lomboz:tableName>Produto</lomboz:tableName> <lomboz:dataSourceName></lomboz:dataSourceName> </lomboz:entity> </lomboz:EJB> <!-- end-lomboz-definition -->]]>

          <ejb-name>Produto</ejb-name>

          br.cefetrn.leilao.beans.ProdutoHome
          br.cefetrn.leilao.beans.Produto
          <local-home>br.cefetrn.leilao.beans.ProdutoLocalHome</local-home>
          br.cefetrn.leilao.beans.ProdutoLocal

          <ejb-class>br.cefetrn.leilao.beans.ProdutoCMP</ejb-class>
          <persistence-type>Container</persistence-type>
          <prim-key-class>java.lang.Integer</prim-key-class>
          False
          <cmp-version>2.x</cmp-version>
          <abstract-schema-name>schProduto</abstract-schema-name>
          <cmp-field >
          <![CDATA[Returns the codigo]]>
          <field-name>codigo</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[Returns the codusuario]]>
          <field-name>codUsuario</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[Returns the codcategoria]]>
          <field-name>codCategoria</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[Returns the codsituacao]]>
          <field-name>codSituacao</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[Returns the produto]]>
          <field-name>produto</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[Returns the descricao]]>
          <field-name>descricao</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[Returns the lancemin]]>
          <field-name>lancemin</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[Returns the datainicial]]>
          <field-name>datainicial</field-name>
          </cmp-field>
          <cmp-field >
          <![CDATA[Returns the datafinal]]>
          <field-name>datafinal</field-name>
          </cmp-field>
          <primkey-field>codigo</primkey-field>


          <query-method>
          <method-name>findAll</method-name>
          <method-params>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[SELECT OBJECT(a) FROM schProduto as a WHERE (a.codSituacao = 1)]]></ejb-ql>


          <query-method>
          <method-name>findProdutosByUserID</method-name>
          <method-params>
          <method-param>java.lang.Integer</method-param>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[SELECT OBJECT(a) FROM schProduto as a WHERE (a.codUsuario=?1) AND (a.codSituacao = 1)]]></ejb-ql>


          <query-method>
          <method-name>findProdutosByCategoria</method-name>
          <method-params>
          <method-param>java.lang.Integer</method-param>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[SELECT OBJECT(a) FROM schProduto as a WHERE (a.codCategoria=?1) AND (a.codSituacao = 1)]]></ejb-ql>

          <!-- Write a file named ejb-finders-ProdutoBean.xml if you want to define extra finders. -->


          <!-- Message Driven Beans -->

          </enterprise-beans>

          <!-- Assembly Descriptor -->
          <assembly-descriptor >
          </assembly-descriptor>

          </ejb-jar>

          Beans XML Descriptor file (beans.xml):
          --------------------------------------------------------------------------
          <?xml version="1.0" encoding="Cp1252"?>


          br.cefetrn.leilao.beans.ProdutoBean
          Entity


          --------------------------------------------------------------------------

          So it's just package all into a .jar (observing the pagkages subdirectories) and put it on server deploy ({jboss-home}/server/default/deploy) directory.


          ** By the "br" from the begining of your nick, I presume you're from Brasil... if so, reply in portuguese cause I'm brazilian too. :)