• 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

Isn't an Handle to an EB dangerous for synchronization?

 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm studying that on an entity bean component stub (or reference) it makes sense to have business methods to Delete, Update, Query that entity, to get the entity home reference (in order to get other entities of the same type) and...get an handle to the entity.

Now, while handles with stateful session beans have got a meaning (because the client is keeping a reference to business logic), I can't see the utility of having an handle to an underlying entity. On the opposite, I see it as potentially dangerous, because in the meantime (I mean between the moment when an Handle is retrieved and the moment when it is re-used to get a reference (or stub) to the EJB[Local]Object it represents) the underlying entity can have been changed by someone else.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...between the moment when an Handle is retrieved and the moment when it is re-used to get a reference (or stub) to the EJB[Local]Object it represents) the underlying entity can have been changed by someone else.



(1) yes, that's true, but the same is true if you use a reference (stub)?

(2) how would you pass a reference of an entity bean to a bean that live's in annother VM / on annother host if not by a handle?

...to the EJB[Local]Object



(3) handles are never used for local objects. Handles are only available on the remote interface

Spec, 9.11:

An entity object�s handle is an object that identifies the entity object on a network. A client that has a
reference to an entity object�s remote interface can obtain the entity object�s handle by invoking the
getHandle() method on the remote interface. The getHandle() method is only available on the
remote interface.

 
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 Severin St�ckli:

(3) handles are never used for local objects. Handles are only available on the remote interface



Yes, of course. Sorry for that. I realized that I put a [Local] that I shouldn't few moments after posting, but was too lazy to go and edit the post again, as the main subject was referring to synchronization and not local or remote. That said, to answer to your question, I would never pass a reference to an entity bean to a remote client. I would prefer to client to get the data itself, so that the container can ensure sync with the underlying persistent storage. If not, who is supposed to realize that sync? My class that passes the Handle to the remote client? I'd never do that...
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic