aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB CMP and DAO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB CMP and DAO" Watch "EJB CMP and DAO" New topic
Author

EJB CMP and DAO

Deepa Malhotra
Greenhorn

Joined: Oct 31, 2003
Posts: 19
My understanding is that for EJB CMP, you dont need DAO. The container can take care of necessary stuff to talk to the database. it this correct?
If so, what happens if I need to change the database?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Deepa Malhotra:
My understanding is that for EJB CMP, you dont need DAO. The container can take care of necessary stuff to talk to the database. it this correct?
Strictly speaking, DAO is a design pattern, and thus in no way comparable to entity beans. You could implement the DAO pattern with entity beans backing it up, or you could implement it with straight JDBC, or JDO, or by any other persistence API. The application code wouldn't see the difference, which is exactly the point in using the DAO pattern.
Originally posted by Deepa Malhotra:
If so, what happens if I need to change the database?

If you're using CMP entity beans and your database needs to change, you need to update your entity bean code and deployment descriptors accordingly. Furthermore, if the modifications show to the application code, you need to update that as well.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Bish Ach
Greenhorn

Joined: Oct 06, 2003
Posts: 26
DAO is used with BMP Entity Ejb.. only
If U use CMP Entity and ur database changes I feel U need a change only in the deployment descriptor cos u dont have any access logic codes in ur cmp bean.Am i correct Lasse???
[ November 03, 2003: Message edited by: Bish Ach ]
yu lei
Greenhorn

Joined: Sep 19, 2003
Posts: 5
if your j2ee system run in WLS or IBM's "where**",you need not the pattren-- DAO. the JNDI pool and DataSource is "DAO".
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Bish Ach:
DAO is used with BMP Entity Ejb.. only
Usually, when DAO is used with EJBs, it's BMP entity beans. However, not always. One could just as well abstract data access away using the DAO pattern and "happen" to implement the operations with the help of the CMP engine...
Originally posted by Bish Ach:
If U use CMP Entity and ur database changes I feel U need a change only in the deployment descriptor cos u dont have any access logic codes in ur cmp bean.Am i correct Lasse???
Yep.
 
jQuery in Action, 2nd edition
 
subject: EJB CMP and DAO
 
Similar Threads
why to use EJB?
EJB and JDBC
DAO or BMP
Confusion - CMP vs Session EJB > DAO
CMP Entity Beans in Component Diagram