Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the trade off on DAO and CMP

 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In some case, we use the CMP to get the data, severval entity beans will be created(just several,not many) and several SQL commands will be execute;if we use DAO ,that will not happen,but if we write so many DAO method to solve almost all the information querying is total violate the o/r mapping?
How can we make the choice?
 
Uwe Schäfer
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from my point of view, dao with session beans is to be prefered, when speed is an issue and the data structures are complex, or (even better) readonly.

dao can help to improve retrieval-speed by using highly optimized queries you are not able to express with the help of EntityBeans+EQL. (Does not happen too often, i think)
of course, you will loose what entity beans and cmp are good for.

on the other hand, if you can tell whether you have to go back to the DB to refresh your entity - or don�t have to - you might win performance over cmp.

i�ve seen mocks where a sb/dao solution is preferred to cmp with these explainations.

another aspect is using EIS systems where cmp is (technically) not an option (say homegrown, non-sql database). DAO prevents cluttering your business code with data-access specific stuff, and makes it easy to "move to cmp, as soon as it is an option" without touching non-dao code.

personally, i would say this option is not adequate too often in real life (as i�ve sen it until today) because you might have to deal with possible bean reuse (even though some articles keep claiming that the properly configured VM is better with that, too) etc yourself.
At least, those guys at bea, ibm or jboss for sure are much better into that, compared to my efforts :roll:
[ November 16, 2005: Message edited by: Uwe Sch�fer ]
 
chao cai
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion,if the query will not lead to big result(many recorders),for example,we want get the email info of a customer,using cmp ,we must find the customer entity first,then get the account entity,get the contactinfo entity finally get the email,this may cause several SQL,but to improve the maitainment it is cost.to use dao,we write many query for different requirement lead to code ugly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic