Two Laptop Bag
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes a few  questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "a few  questions" Watch "a few  questions" New topic

a few questions

manish ahuja
Ranch Hand

Joined: Oct 23, 2003
Posts: 312
1) In a stateless session bean component interface we can have only 1 create method with no args parameter. Why cant we have a create with arguments. Though i find it in every book or tutorial that we cant have a create with arguments in slsb no one actually clarifies why we cant have one & what if we have 1. what would be the consequences
2) Why Entity Beans???. What is it that we cant do with session beans that we have to resort to entity beans apart from entity beans surviving a server crash
3) How are Message Driven beans more effecient. Apart from not having a component or home interfaces what are the advantages of having MDB. What if we have the same logic in Session or entity beans
4) Where should we actually have database access code in a session or entity bean. How to decide when to use database interaction activities from session beans or entity beans
5) How to ensure cross database & cross schema portability of our EJB code
6) In stateful session beans what are the use of arguments passed with the create methods
Sudhir V
Ranch Hand

Joined: Dec 25, 2002
Posts: 143
Answer to the first question:
In stateful beans the create method is overloaded mainly to send client specific information to the bean and coz bean is created on client demand and is attached to the client till he removes it so it can preserve that information till the end.
But for stateless beans there are many reasons
1) these beans already exist in pools and are assigned to client on business method invocations hence any information to be passed to the bean is done thrugh business method arguments.
2)these Beans cannot hold client specific information and conversational state so there is no need to pass info in a create method to the bean.
In summary since the bean is not assigned to the client during the create process so we cannot send information to the bean.
[ February 08, 2004: Message edited by: Sudhir Vallam ]

Sudhir V<br />(SCJP 1.2, SCWCD, OCA, SCBCD)
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
1. All SLSB with the same home are identical. There is no gain in having overloaded create() methods.
2. Entity beans represent business objects.They have a direct mapping to the database tables.
The entities/rows in the database can be created/updated/deleted. Session beans are used
for business logic or modulate a workflow business process.
3. MDBs are efficient for asynchronous messaging, so there is no blocking.It is much appreciated in a project that uses JMS.
Session/Entity beans are used for synchronous communication. The bean client is blocked, until it gets a response from the ejb.
4. You need to study EJBs more in detail. You can refer the EJB Design Patterns book at or go thru SUN's examples, including PetStore.
5. EJB-QL is used for CMP2.0 entity beans. You can try to use DAO patterns for the others.
6. SFSB always hold client specific data, so overloading of the create() methods makes sense.
It would be easy to pass most of the parameters in one call to the SFSB rather than multiple calls.

Hope that helps!
[ February 10, 2004: Message edited by: Vish Kumar ]
Ben Dover
Ranch Hand

Joined: Jan 30, 2004
Posts: 91
Homework assignment???
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
Originally posted by Louis Saha:
Homework assignment???

So...... do I get the job
I agree. Here's the link:
subject: a few questions
It's not a secret anymore!