Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Question about EB remove

 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So far I know that, when the client invokes remove() for an entity bean (this could happen, directly on the EJB[Local]Object reference, or on the bean's home reference (if the client is remote, through EJBHome.remove(Handle h), EJBHome.remove(Object key) );

In all cases, the remove method causes the underlying entity to be deleted, and the bean instance to be put back into the pool. That's right.

But what happens to the EJB[Local]Object? With the plain remove and EJBHome.remove(Handle h) I guess the EJBObject on the server gets deleted. What happens with EJBHome.remove(Object key)? I'm reading the specs (chapter 9.5.3.) but the only thing it is said is that, if the client tries to use EJBObject after remove has been invoked, it will get a java.rmi.NoSuchObjectException
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im not too sure it, but I'll give it a shot.

I think calling all versions of Remove will remove the EJB[Local]Object from the server. If we take a look back at how the EJBObjects are created, they can be created either by
1. findByPrimaryKey
2. create(....)

1. From HFEJB, it says the the Container makes or finds an EJB Object for a specific entity, in this case #27. Thus, an EJB Object to #27 can only exist IF there is a corresponding row in the database. Now, if the row was deleted, then there shouldnt be a EJB Object for #27. BUT would there still be an EJB Object, but without the primary key on the object (so we can re-use it)? I dont think the container will go through all that trouble trying to remove the primary key linked to the EJB Object, and then putting it in some secondary storage, and then achieving it later for re-use. As we see, the EJB Object isnt pooled, as the context is (what i see from diagrams).

2. For creating a new row in the database, the container will create a new EJB Object, in between EJBCreate and EJBPostCreate.

Thus, if Remove didnt remove the EJB Object, I dont see the use of keeping it in the server, since in both scenerios, the container will create a newly create EJB Object.

Hope i didnt get all of it wrong
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ryan Wong:
Im not too sure it, but I'll give it a shot.

I think calling all versions of Remove will remove the EJB[Local]Object from the server. If we take a look back at how the EJBObjects are created, they can be created either by
1. findByPrimaryKey
2. create(....)

1. From HFEJB, it says the the Container makes or finds an EJB Object for a specific entity, in this case #27. Thus, an EJB Object to #27 can only exist IF there is a corresponding row in the database. Now, if the row was deleted, then there shouldnt be a EJB Object for #27. BUT would there still be an EJB Object, but without the primary key on the object (so we can re-use it)? I dont think the container will go through all that trouble trying to remove the primary key linked to the EJB Object, and then putting it in some secondary storage, and then achieving it later for re-use. As we see, the EJB Object isnt pooled, as the context is (what i see from diagrams).

2. For creating a new row in the database, the container will create a new EJB Object, in between EJBCreate and EJBPostCreate.

Thus, if Remove didnt remove the EJB Object, I dont see the use of keeping it in the server, since in both scenerios, the container will create a newly create EJB Object.

Hope i didnt get all of it wrong



Well, I think that the EJBObject gets removed too, but I am worrying about a possible question like:

Referring to entity beans, what happens to the EJBObject if a remote client invokes EJBHome.remove(Handle h)?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic