• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ejbRemove - invoked on local call?

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The EJB spec mentions:

The container invokes the ejbRemove method on an entity bean instance with container-managed persistence in response to a client-invoked remove operation on the entity bean�s remote home or remote interface.

So that means only when using a remote interface, ejbRemove should be invoked - this seems a bit silly though - I am using a local interface using a controller facade - I need the entity bean to perform checks on ejbRemove i.e. referential integrity, but it is not invoked when remove() is called from a local interface? Is this a gap in the EJB spec or am I missing something here?
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the API doc, there are remove methods declared in the local interfaces as well.
 
Johann Evans
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, but the problem lies with the EntityBean ejbRemove() - this is almost like an event, that is fired when a client calls the remove method - now calling the remove from a remote interface will invoke ejbRemove, but calling the local interface remove does not invoke ejbRemove and I believe this is why the spec states "remote" interface.

I suppose the best place to encapsulate "pre-delete" behaviour is ejbRemove, but the container does not invoke it when remove() using a local interface?
 
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Johann Evans:
The EJB spec mentions:
The container invokes the ejbRemove method on an entity bean instance with container-managed persistence in response to a client-invoked remove operation on the entity bean�s remote home or remote interface.



The above statement is present in section 14.1.3, and section 14 is titled "EJB 1.1 Entity beans with container-managed persistence". That's probably why only the remote interfaces are mentioned.

I searched in the specs but could not find anything. So still have no answer to your question. Its strange, I (or most people for that matter) would expect the same behaviour for local beans, but then you are saying it is not happening. Hope someone has an explanation. By the way, which application server are you using?

- Sheldon Fernandes
 
Johann Evans
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using JBoss

I've tried to search for similar behaviour, but it seems this is a general problem across application servers.

I'm pretty sure one should implement pre-delete behaviour in ejbRemove i.e. checking dependencies and being able to throw an Exception to abort the remove..
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would make no sense at all for remove to be invoked only by a remote client. The EJB 2.0 spec says:


10.7.8 Entity EJBLocalObject class
The entity EJBLocalObject class, which is generated by deployment tools, implements the entity bean�s local interface. It implements the methods of the javax.ejb.EJBLocalObject interface and the local business methods specific to the entity bean. The implementation of the remove() method (defined in the javax.ejb.EJBLocalObject interface) must activate an instance (if an instance is not already in the ready state) and invoke the
ejbRemove method on the instance.

The implementation of each local business method must activate an instance (if an instance is not already in the ready state) and invoke the matching business method on the instance.

 
Sheldon Fernandes
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roger that
 
Johann Evans
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys - I'm going to setup a test case and forward it to JBoss to see if this issue is internal...
 
reply
    Bookmark Topic Watch Topic
  • New Topic