aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes dependent entity beans - calling another entity bean's remove method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "dependent entity beans - calling another entity bean Watch "dependent entity beans - calling another entity bean New topic
Author

dependent entity beans - calling another entity bean's remove method

John Oo
Greenhorn

Joined: Jun 01, 2001
Posts: 1
Please help! I've got a 2 tables where one table (A) has a foreign key to another table(B). When I'm doing a remove, I have to remove the entry in table (A) before I can remove the entry in table (B). So, in the entity bean for table B's ejbRemove() method I'm trying to call the remove method of table A's entity bean. However, I'm stuck inside a loop inside the ejbRemove() method of table B's entity bean. It gets stuck when I try to get the home interface. Should I be even be doing this in the ejbRemove() method? Is that what this method is for? Here's what I have
public void ejbRemove() throws RemoteException, EJBException
{
Debug.println("extended description is not empty");
RequisitionDescriptionPK pk = new RequisitionDescriptionPK(primary_key);
RequisitionDescriptionHome home = (RequisitionDescriptionHome)EJBFactory.getHome(RequisitionDescriptionHome.class);
Debug.println("got home interface");
RequisitionDescription reqDescription = home.findByPrimaryKey(pk);
Debug.println("Got remote interface");
reqDescription.remove();
Debug.println("removed extended description");
}
Any help or suggestions you can give me would be appreciated. Thanks.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

There is a section in the Developer's Guide that is helpful. There are a few ways to do one-to-many relationships with entity beans.
http://java.sun.com/j2ee/j2sdkee/techdocs/guides/ejb/html/Advanced2.html#11700

It is helpful to download the code and examine the full code of the beans they talk about... they only provide snips of them in the document.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dependent entity beans - calling another entity bean's remove method