• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Removing an Entity Bean

 
Francesco Marchioni
author
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
While studying for the exam I have come across a doubt: is there any difference between

1) removing an Entity bean through the Home interface:

void remove(Object aPrimaryKey) throws RemoteException, RemoveException;

and

2) calling directly remove() on the EJBObject, for example when you have issued a findByPrimaryKey before ?

I can see that both works for removing data from the DB, but is there are difference in the lifecycle of the EJB or any kind of constraint using one instead of the other.....

Hope I was clear
regards
Francesco
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much of a difference lifecyce wise or in any other way. Both removes would remove the underlying entity, do the required cascade deletes and toss out the EJBObject instance for that entity. Note that a bean would typically be activated and loaded from the pool with the about-to-be-deleted entity's data and it's ejbRemove() method called before deleting the underlying entity. Once the delete including cascade deletes are done, the bean instance would lose it's identity and go back to the pool (without getting a passivate call). All this is the same for both removes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic