• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Will I have two shopping carts?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have recently started reading HFEJB and into the third chapter now. I have a question on isIdentical?

The book says, isIdentical(Object o) always returns false for stateful session beans. Say, we have a ShoppingCart Stateful Session Bean. I obtain its component interace (or a stub to EJBObject) from its home interface (or stub of EJBHome). I put some stuff into the cart and now say some how I lost the reference to the component interface. Now is there no way to get the reference to the same component interface? I am thinking that calling create on the stub to the home interface will create another Session Bean on the server for the statement given in the book to be true. So I end up with a new and empty shopping cart? Am I right, here?

I hope my question is clear
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The book says, isIdentical(Object o) always returns false for stateful session beans.


YES. If the 2 beans are stateful bean, even the content is the same, isIdentical() returns false.

But if the 2 beans are stateless bean which come from the same home, isIdentical() returns true.


Say, we have a ShoppingCart Stateful Session Bean. I obtain its component interace (or a stub to EJBObject) from its home interface (or stub of EJBHome). I put some stuff into the cart and now say some how I lost the reference to the component interface. Now is there no way to get the reference to the same component interface?


YES, you will get a new EJBObject if you lose the old reference. Unless you save the EJBObject locally for future use, otherwise, if you lose it, you lose it forever.


I am thinking that calling create on the stub to the home interface will create another Session Bean on the server for the statement given in the book to be true. So I end up with a new and empty shopping cart? Am I right, here?


YES. For every create() call, you will create a NEW EJBObject, and thus, those old information are gone!

Nick
 
Vishy Anand
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Cheung. It looked kind of weird initially for me, but now makes sense to me. Thanks again, for the reply.
 
Vishy Anand
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now what if I pass the same stub to the component Interface of a StatefulBean? Will it still return false?

Example:

ShoppingCart sc = scHome.create();
What does sc.isIdentical(sc) return for stateful beans?
 
Vishy Anand
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Waiting for the reply on the above question. Any EJB expert out there, reading this?
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Vishy Anand:
Waiting for the reply on the above question. Any EJB expert out there, reading this?



Not an expert

But result will be true. Spec. page 66.

V.
 
Vishy Anand
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Vitaliy. For pointing me toward the specs. I have gone through the Client's view of Sesson Bean chapter on the spec and it was easier to understanf than the HFEJB book. It may be only because I have already read it in HFEJB Book.

Anyway Thanks again and from now onwards I will also refer the spec.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic