Prev | Next

TOC | Index

J2EETM Developer's Guide
Entity Beans


Passing an Entity Bean's Object Reference

If you want to pass an entity bean to another bean, you can't pass the this reference. Instead, you must pass the entity bean's object reference. The following code snippet shows how to retrieve the object reference by calling getEJBObject on the EntityContext of an entity bean.

public void setEntityContext(EntityContext ec) { 
   // save the entity context in an instance variable
   this.context = ec; 
}
   . . .
public void passItOn(Inventory tally) { 
   // pass the object reference
    tally.copyItems(context.getEJBObject()); 
}



Prev | Next

TOC | Index


Copyright © 2000 Sun Microsystems, Inc. All rights reserved.