Hi all,

i'm facing problem in finder method of composite primary key. I've implemented a 
method which find all records of table. i've implemented method in ejb-jar.xml file 
which returns collection of entity beans objects. i'm using session facade method. i'm 
accessing get method of cmp bean in session bean but it's gives error saying tat 
entity not found with composite primary key. but if i'm creating entity bean object 
using findbyprimarykey method then it can access cmp bean methods. 

here's code of pk file

package cmp.shippingcharges;

import java.io.Serializable;

public class ShippingChargesPK implements java.io.Serializable 
{
        public String frontEndId;
        public String transportId;
        
        public ShippingChargesPK(String frontEndId, String transportId)
        {
                this.frontEndId=frontEndId;
                this.transportId=transportId;   
        }
        
        public ShippingChargesPK()
        {
        }
                
        public String getFrontEndId()
        {
                return frontEndId;
        }
        
        public String getTransportId()
        {
                return transportId;
        }       
        
        public String toString()
        {
                return frontEndId+"-"+transportId;      
        }
        
        public boolean equals(Object obj)
        {
                if(obj instanceof ShippingChargesPK)
                {
                        ShippingChargesPK otherkey=(ShippingChargesPK) obj;
                        
                        if((otherkey.frontEndId==frontEndId) && 
(otherkey.transportId==transportId))
                                return true;
                        else
                                return false;
                }
                else
                        return false;   
        }
        
        public int hashCode()
        {       
                StringBuffer sb=new StringBuffer();
                
                sb.append(frontEndId);
                sb.append(transportId);
                
                String keys=sb.toString();
                int hashCode=keys.hashCode();
                
                return hashCode;
        }
        
}

and code of session bean is as follows::

while(i.hasNext())
                        {
System.out.println("Remote Create 1");
                                
  sc=(ShippingCharges)i.next();
                                
System.out.println("Remote Create 2");
ShippingCharges sctemp=shome.findByPrimaryKey(new ShippingChargesPK("F1","T1"));
System.out.println("found by primarykey method 1");

System.out.println("FrontEndOffice->"+sctemp.getFrontEndId());
System.out.println("TransportMode->"+sctemp.getTransportId());
System.out.println("found by primarykey method 2");
//upto this works well but below call gives error
//sc is an object return by findall method

System.out.println("TransportMode->"+sc.getFrontEndId());

                                
ShippingChargesRecord scr=new 
ShippingChargesRecord(feo.getName(),tm.getTransportMode(),sc.getCost(),sc.getUnitWeight());
                        
                                a.add(scr);
                        
                        }

any help would be very much helpful


Kiran....

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3840093#3840093

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3840093


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to