• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejb with DAO

 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

whats the better/best approach among the three options below

Stateless session beans with DAO
Stateful session beans with DAO
BMP entity beans with DAO




thanks
J
 
ManojKumar Unnikrishnan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
That would depend on the kind of persistance requirement you have.
1.Stateless is used for better performance and when state of the client need not be stored.
2.Stateful session beans would be used when the requirement is contrary.
3.CMP is helpful for faster development of the persistent mechanism and if compilcated SQL's are not involved in implementing the business process.
 
ManojKumar Unnikrishnan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would also like to add that DAO only serves the purpose of decoupling the beans from the database access.It would also make sense to use them, if you are expecting schema switches or database switches.
 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>>That would depend on the kind of persistance requirement you have.
Agree with you.

which one would you choose from the below two options

1. Stateless session beans(acting as facade) --> BMP entity bean -- > DAO(will handle the persistance)

2.Stateless session beans(acting as facade) --> DAO -->(will handle the persistance)


Assuming a scenario that user must write code to handle the persistance in DAO, the second option is more simpler because it does not have the extra layer(of BMP entity bean). My question is
"Is there any special advantage of putting that BMP entity bean layer in between session bean and DAO. Does it improve the performance or do you think we can avoid it?

thanks
J
 
Rich Veress
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, if you have multiple clients using same data
 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>>>>yes, if you have multiple clients using same data

can you be a little more specific on what you are saying.

thanks,
J
 
Ricardo Ferreira
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rich has told you that if you worry with thread access synchronization by multiples clients to the same entity, BPM entity beans could improve the system synchronization.

Remember that each entity at your database will be mapped for one entity bean instance managed by the ejb container. Without entity beans (CMP or BPM), your DAO code must ensure that multiple transactions does not override the business data.

Transaction are complicated to maintain with programmer code, you have to believe that isolation levels and transaction scoping will help you to manage this.

But in fact, distributed application require extra runtime code to manage multiple access from remote clients (web application, CORBA Clients).

This is the motivation for Entity beans. If your application does not worry with multiple access at the same time, only a data access layer with DAO components is enough. At most enterprise projects, this is really enough, but try to figure it out the submarino.com application or the travel reservation system, that need to access the same data, by multiples clients ?

Think about that!
 
Rich Veress
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ricardo is correct. In addition to this, you save memory by having a single instance of the object intead of having multiple copies for each individual client. Entity beans have their own role...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic