This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi 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 Rgrds
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 ]
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 http://www.theserverside.com/books/wiley/EJBDesignPatterns/index.jsp 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 ]