Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DAO with statefull session bean

 
Vaithiya Sundaram
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
105 When would you use the DAO pattern in regards to a Stateful Session Bean?
DAO = Date Access Object CMP = Container Managed Persistence BMP = Bean Managed Persistence

A When using CMP to reduce dependence on underlying data store.

B When using BMP to reduce dependence on underlying data store.

C When using BMP to increase performance.

D When using CMP to increase performance.

E You wouldn't use a DAO with Stateful Session Beans.

F When writing to a temporary store when ejbPassivate() is called

Ans: Choice E is correct.

But I have doubt why can't we use DAO for Statufull Session beans?
If we can use DAO with Statufull Session beans we can tick the answer B.
 
Manik Saha
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even I choose B as the answer. After I went through the answers, the only 2 reasons I could think of are
- DAO's make more sense when used with BMP entity beans (hence the question would read more like which type of beans would you possibly use DAO with)
- Stateful session beans would possibly instantiate 1 instance per usage (unless using some singleton DAO, which has another set of problems such as concurrency issues etc).

Anyone has other comments ?
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm...lets' see.


A When using CMP to reduce dependence on underlying data store.

Not correct. Needs no explanation.



B When using BMP to reduce dependence on underlying data store.

Yes. In fact use of a DAO pattern is encouraged with BMPs.


C When using BMP to increase performance.

Yes. Heard about bi-modal data access or fast lane readers?



D When using CMP to increase performance.

Nope.


E You wouldn't use a DAO with Stateful Session Beans.

Vague answer. The statement is too broad. What if you are not using entity beans? What if I use a SLSB layer between the DAO and the SFSB? Does the answer preclude this option or is it trying to imply nothing in between the SFSB and the DAO?



F When writing to a temporary store when ejbPassivate() is called

Again, a totally unrelated option. It appears as though some one threw this one just because they wanted to have a fifth option


HTH
 
Deepak Pant
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me add my 2 cents as well...

Stateful Session Bean is used to maintain the conversational state on behalf of the user across different activities (may be screen/workflow).

These activities would map to atleast 1 or more use cases. By this logic the SFSB would be implemented based on Session Facade.

Typically Session Facade uses one or more Business Objects (POJO or Entity Beans) to complete the business process.

In this context Answer E is correct.

Now one can argue that Session Facade can straight away use the DAO like in case of ValueListHandler design pattern.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic