I'd like to understand how to properly use EJB remove() method. Per EJB specs it can be declared in both remote and home interfaces. When should I use home vs remote.
what what what..
Please make the Question more clear......
ejbRemove in all cases will remove the bean instance from the container
Clients can't call ejbRemove directly, they must use remove() method in home or remote interfaces.
I'd like to know when should I use remote or home interfaces.
A total of 3 remove methods are defined in javax.ejb.EJBObject and javax.ejb.EJBHome interfaces and you should not override them when creating your own remote and home interfaces. You can use any of the three in you client code, but be aware of the method signature differences. Eventually the ejbRemove method of the bean class gets called by the container to remove the EJB instance.
The remote remove() can be used to delete a bean when you have an active reference to the bean i.e. a stub.
The home method remove(Object pk) can be used to delete an entity bean when you have the primary key alone. It performs the same operation as Remote.remove() except that you don't need a stub.
The home method remove(Handle handle) permits the deletion of session and entity beans by Handle alone (no stub required).
uhm ok maybe im too dizzy after an all nighter, but
does delete in
"The home method remove(Object pk) can be used to delete an entity bean when you have the primary key alone"
means deleting a row in table or forcing the entity to passivate in the container?
Removing an entity bean always deletes it from the table. An entity exists when the row exists. The in-memory bean is simply a cached object, think of the container as a cache manager. Activation, passivation, load & store are simply lifecycle management callbacks. Section 9.1.4 of the EJB1.1 spec. should clear this up for you.