• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to compare two stateful objects

 
james edwin
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Well it doesn't make sense to compare two stateful objects,but if i want to compare two stateful session objects how can i do it ? Like i can use isIdentical(EJBObject obj) for stateless...this will not work for stateful.

In stateful,how can i compare two stateful session objects ?

Regards,

Deepak
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just try to compare using isIdentical() method and you will always get false value as the return value... Since they are tied to a specific client, each of them always are different... Why do we have to waste our time on comparing such thing?
 
Girija Siva
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James
What do u mean by comparing two stateful objects. If u want to see if they represent same client or not(same bean) you can use isIdentical(). It will return true if both ur references are using the same Bean
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Girija Siva:
James
What do u mean by comparing two stateful objects. If u want to see if they represent same client or not(same bean) you can use isIdentical(). It will return true if both ur references are using the same Bean

James, I don't think stateful objects are sharable... They always return false, even though they come from the same home according to HF EJB... I do believe that each client will receive a reference to different beans and they are different as they will be dealing with a specific client, one and only...
 
james edwin
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you all for Replies.

I argee we can can't use isIdentical() method.What i am asking is,can we use any other method or what's the way if repeat if we want to compare two stateful objects ?

Regards,

James
[ May 25, 2004: Message edited by: james edwin ]
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by james edwin:

I argee we can can't use isIdentical() method.What i am asking is,can we use any other method or what's the way if repeat if we want to compare two stateful objects ?


Mmm...I'm afraid there is no way to do such thing in Stateful Session Beans...
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect we are talking about two completely different issues here.

1. Given two different stateful beans, if I have some notion of 'equality' based upon the detailed state of that bean, how do I test for equality?
Answer: Write a business method for it, and pass a reference to the other bean.


2. Is it ever possible to have two references to a stateful bean and have isIdentical return true?

Definitely. You obviously can't use home.create() twice and ever have isIdentical be true - you'll have created two separate bean instances. But that is a very limited idea of where bean references come from. You could have obtained beans in a collection, as parameters to a method, or via a handle. In that case you may not know which, if any, of the references are to the actual same bean instance, and the 'equals' method isn't going to cut it. The only way to identify duplicate references to the same actual stateful session bean will be via isIdentical.
[ May 26, 2004: Message edited by: Reid M. Pinchback ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic