• Post Reply Bookmark Topic Watch Topic
  • New Topic

how many EJBObjects

 
sanj singh
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
If I have a reference to the EJBHome interface as say..
ABCHome abc=null;
Now if I call the create()method thus..
abc.create("123");
abc.create("456");
and so on....
Would there be an EJBObject created for each invocation of create() method or would there be only one instance.
Regards
sanj
 
Kartik Shah
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it depends upon the type of EJB used.
If it is Statefull session bean it will
FooHome fooHome = ...; // obtain home of a stateful session bean
Foo foo1 = fooHome.create(...);
Foo foo2 = fooHome.create(...);
if (foo1.isIdentical(foo1)) {// this test must return true
...
}
if (foo1.isIdentical(foo2)) {// this test must return false
...
}
If this is stateless session bean second if will return true as it does not matter.
For Entity Beans
"If two entity objects have the same home and
the same primary key, they are considered identical."
"Alternatively, if a client obtains two entity object references from
the same home, it can determine if they refer to the same entity by comparing their primary keys using
the equals method."
So in your case if it is Entity beans object it two objects will be there.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!