This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
John Oo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic