Hiiii According to the ejb specifications the remove() will remove the ejb object but in my code after calling remove()on an ejbObject,still i am able to call my businessmethods on the same EJBObject in case of stateless sessionbean where it should show the exceptions.But in case of entitybean i am getting exceptions if i am calling any methods on the removed ejbobject...
If you closely look on the specification of remove(callback/lifecycle) method then for session bean it is used with stateful session bean. Actually it is not a callback method because application code call it and not the container. When you deal with stateful session bean and calling this method then the bean instance associated with the calling code get detached and if you try to call any method then it will throw and exception... When you deal with stateless session bean it will not have any impact because container may or may not send you the same instance od session bean and there we dont have any particular instance associated with calling code.
If you deal with entity bean and call remove method(it is same as called from application code and not from the container) then all the changes will be lost if you have not commited to the database and its instance will be removed from the EntityManager managed context.
So when you are calling remove for stateless session bean you wont get the exception(as i have explained you) and you will get the exception for entity bean(as you are getting) bean.
Let me know if i have explained you.....
Cheers !!! Sumit
If at first you don't succeed, don't try skydiving
But as per Richard Monson Haefel (O Reilly - Enterprise Java Beans)
Stateless session beans may also have a timeout period and can be removed by the client, but a timeout or remove operation simply invalidates the EJB object reference for that client; the bean instance (on the server) is not destroyed and is free to service other client requests.
Invalidation should have occured. But as the bean is stateless it does not harm any one when it services business methods further. [ January 09, 2007: Message edited by: karthi keyan ]
thanks for your tips...actually i also think like that in some other point of is that....in stateless session bean no activate and passivate methods are there...means bean without any state which means..the same SLSB can be used for other client..so the container thinks no need to remove the bean as it reuseable... Thanking you Bharat with Regards