Peter Shillan wrote:
> 
> Hi Folks,
> 
> I have a query about Finder method generation in CMP beans. I have copied an
> example customer bean from "Mastering Enterprise JavaBeans" and it uses CMP.
> The book assures me that
> 
>  *   @finder Collection findByExpensiveProduct( double minPrice )
>  *   @finder Collection findCheapProducts( double maxPrice )
> 
> will be generated, but they're not cause they don't match any fields in the
> object and I agree... how on Earth could a container generate methods for
> these finders? Can I simply implement them myself as if they were BMP?

Hi, 

For this kind of finders, you have to provide the sql statement in
jaws.xml.  See http://www.jboss.org/jawsxml_howto.html for details and
examples.

HTH,

Sebastien



> Thanks in advance,
> 
> Peter.
> 
> - - 8< - - [ CODE ] - - 8< - -
> 
> package uk.co.gps.jasmine;
> 
> import java.util.*;
> import java.rmi.*;
> import javax.ejb.*;
> 
> import uk.co.gps.ejb.EntityBase;
> 
> /**
>  *   This is an product bean.
>  *
>  *   @see <related>
>  *   @author $Author: peters $
>  *   @version $Revision: 0.0.1 $
>  *
>  *   @entity-cmp
>  *   @ejb-name Product
>  *   @finder Collection findByName( String name  )
>  *   @finder Collection findByDescription( String description )
>  *   @finder Collection findByBasePrice( double basePrice )
>  * The following is not generated:
>  *   @finder Collection findByExpensiveProduct( double minPrice )
>  * The following is not generated:
>  *   @finder Collection findCheapProducts( double maxPrice )
>  *   @finder Collection findAllProducts()
>  *   @transaction Required
>  */
> public abstract class ProductBean extends EntityBase
> {
>     public String productID;
>     public String name;
>     public String description;
>     public double basePrice;
> 
>     //
>     // Business Logic Methods
>     //
> 
>     /**
>      * @remote-method
>      * @cmp-field
>      */
>     public String getName() throws RemoteException
>     {
>  return name;
>     }
> 
>     /**
>      * @remote-method
>      * @cmp-field
>      */
>     public void setName( String name ) throws RemoteException
>     {
>  this.name = name;
>     }
> 
>     /**
>      * @remote-method
>      * @cmp-field
>      */
>     public String getDescription() throws RemoteException
>     {
>  return description;
>     }
> 
>     /**
>      * @remote-method
>      * @cmp-field
>      */
>     public void setDescription( String description ) throws RemoteException
>     {
>  this.description = description;
>     }
> 
>     /**
>      * @remote-method
>      * @cmp-field
>      */
>     public double getBasePrice() throws RemoteException
>     {
>  return basePrice;
>     }
> 
>     /**
>      * @remote-method
>      * @cmp-field
>      */
>     public void setBasePrice( double basePrice )
>     {
>  this.basePrice = basePrice;
>     }
> 
>     /**
>      * @remote-method
>      * @pk-field
>      * @cmp-field
>      */
>     public String getProductID() throws RemoteException
>     {
>  return productID;
>     }
> 
>     //
>     // Get and Set data object
>     //
> 
>     /**
>      * @remote-method
>      */
>     public abstract void setData( ProductData data ) throws RemoteException;
> 
>     /**
>      * @remote-method
>      */
>     public abstract ProductData getData() throws RemoteException;
> 
>     //
>     // EJB Methods
>     //
> 
>     public ProductPK ejbCreate( ProductData data )
>  throws RemoteException, CreateException
>     {
>  setData( data );
> 
>  return null;
>     }
> 
>     public void ejbPostCreate( ProductData data )
>  throws RemoteException, CreateException
>     {
>     }
> }
> 
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Problems?:           [EMAIL PROTECTED]


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to