Thanks Mr. Young for your inputs ... What i wanted to know is that ... does the CMR ... support this type of methods .
I am using the Local Interface for the Entities
Maybe we have to do is just specify the EJB-QL and the rest can be taken care by the container ..
 
Regards,
Vikram Naik
----- Original Message -----
From: Rob Young
Sent: Thursday, June 05, 2003 12:59 PM
Subject: Re: Reg CMR EJB 2.0

Hi Vikram
 
I'm assuming you want the method getEntityB( "value of detail 1" ) to be a member of Entity A.
 
Here's a way of doing it. Not sure if it's the best way.
 
/**
 * @return An instance of EntityBRemote with its <code>detailOne</code> field
 * equal to <code>detail1</code>. Returns <code>null</code> if no such EntityB
 * exists or no such EntityB exists in this Entity A's collection of Entity Bs.
 */
public EntityBRemote getEntityB(String detail1){
 
    EntityBRemote  returnValue  = null;
    EntityBHome entityBHome = null;
    EntityBRemote entityBRemote = null;
    Collection entityBCollection = null;
 
    /* Let's suppose you have another method you can call for
     * retrieving the Home interface of Entity B.
     */
    entityBHome = getEntityBHome();
 
    try{
        entityBRemote = entityBHome.findByDetailOne(detail1);
 
        /* Note that I think you should change your method name from
         * getEntityB() to getEntityBs()
         */
        entityBCollection = getEntityB();
 
        if(entityBCollection.contains(entityBRemote){
            returnValue = entityBRemote;
        }
    }
    catch(FinderException e){}
    catch(RemoteException e){}
 
    return returnValue;
}
 
 
----- Original Message -----
Sent: Thursday, June 05, 2003 8:12 PM
Subject: Reg CMR EJB 2.0

Hello All,
 
Suppose I have two database tables A and B.
 
Scehma of A
 
NAME (pk)
VALUE
 
Scehma of B
 
ID (pk)
NAME ( Foreign Key from A)
DETAIL1
DETAIL2 
 
 
A and B have master detail relationship . ( like order and lineitem )
 
so we create a CMP Entity A which has One to Many relationship with Entity B.
 
Now Entity A can have methods exposed like ..
 
Collection getEntityB()
 
My Queries are :-
 
1) I wanted to add another argumented method so that i can have a specific row selected from Entity B where value of DETAIL1 can compared along with the foreign key.
 
getEntityB( "value of detail 1" )
 
 
Can be this done ... , if yes please guide .
 
Thanks
Vikram

Reply via email to