  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Subject: Session - > DAO - > CMP | Subject: Session - > DAO - > CMP 2004-06-09 - By Huy Nguyen
Back There are three logical path
> Session -> BMP ( + DAO for implement DB tx). This is bad choice if your app is J2EE 1.3 and above. Network round trip (N+1 problem) between DB and Entity EJB will propably kill your app performance.
> Session -> CMP. You will have better performance and simpler to implement
> Session -> DB (via SQL) good for batch upload or retrieval.
Either of all above wont break your client code. I suggest to use option 2.
good luck!
-h
Guy Katz <gkatz@(protected)> wrote: hi; using CMP, you bind your self to a DB. I makes sense to put a DAO in front of an entity bean (cmp or bmp) if you want to abstract your persistence mechanism. if you do not want to rely on entity bean for your persistence, than putting a DAO in front is a good idea. you will be able to switch between entity beans, hibernate, jdo and so forth. if you are using EJB for your persistence, than I don't see any special benefit here.
specifically about what you asked, the situation you describe fit to having a BMP entity bean and a DAO behind it (assuming an EJB centric persistence mechanism). the BMP will call the DAO of choice (XMLFileDao, DataBaseDAO). so as you can understand from my answer.
-- --Original Message-- -- From: Koala [mailto:koala.gnu@(protected)] Sent: Wednesday, June 09, 2004 10:25 AM To: J2EEPATTERNS-INTEREST@(protected) Subject: Session -> DAO -> CMP
Hi,
I would like to know if it makes sense have DAO in front of an entity bean CMP. For example:
Client --> Session Facade --> DAO --> EntityBean
Probably this scheme could have some advantages:
1) the back end (DB or XML file) is abstracted. (I can abstract an XML file behind a CMP bean?) 2) I can move my application written in DAO quicly in EJB without changing client code.
and so on.
But, if I am writing a new application, does it make sense use this schema? If so, what are the advantages? Thanks for your help in advance.
PS
if you have links talking about this use of DAO please let me know. (Do not send me mail of sites talking about general use of DAO).
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
huy.nguyen
(t)+612 9271 3241 (e) d_huy_nguyen@(protected)
-- ---- ---- ---- ---- ---- ----- Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger
==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected) <DIV>There are three logical path</DIV> <DIV> </DIV> <DIV>> Session -> BMP ( + DAO for implement DB tx). This is bad choice if your app is J2EE 1.3 and above. Network round trip (N+1 problem) between DB and Entity EJB will propably kill your app  ;performance.</DIV> <DIV> </DIV> <DIV>> Session -> CMP. You will have better performance and simpler to implement</DIV> <DIV> </DIV> <DIV>> Session -> DB (via SQL) good for batch upload or retrieval.</DIV> <DIV> </DIV> <DIV>Either of all above wont break your client code. I suggest to use option 2 .</DIV> <DIV> </DIV> <DIV>good luck!<BR></DIV> <DIV>-h</DIV> <DIV><BR><B><I>Guy Katz <gkatz@(protected)></I></B> wrote:</DIV> <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER -LEFT: #1010ff 2px solid">hi;<BR>using CMP, you bind your self to a DB.<BR>I makes sense to put a DAO in front of an entity bean (cmp or bmp) if you<BR>want to abstract your persistence mechanism.<BR>if you do not want to rely on entity bean for your persistence, than putting<BR>a DAO in front is a good idea. you will be able to switch between entity<BR>beans, hibernate, jdo and so forth.<BR >if you are using EJB for your persistence, than I don't see any special<BR >benefit here.<BR><BR>specifically about what you asked, the situation you describe fit to having<BR>a BMP entity bean and a DAO behind it (assuming an EJB centric persistence<BR>mechanism). the BMP will call the DAO of choice (XMLFileDao, DataBaseDAO).<BR>so as you can understand from my answer.<BR><BR>-- ---Original Message-- --<BR>From: Koala [mailto:koala.gnu@(protected)]<BR>Sent: Wednesday, June 09, 2004 10:25 AM<BR>To: J2EEPATTERNS-INTEREST@(protected)<BR>Subject: Session -> DAO -> CMP<BR> <BR><BR>Hi,<BR><BR>I would like to know if it makes sense have DAO in front of an entity<BR>bean CMP. For example:<BR><BR>Client --> Session Facade --> DAO --> EntityBean<BR><BR>Probably this scheme could have some advantages: <BR><BR>1) the back end (DB or XML file) is abstracted. (I can abstract an XML <BR>file behind a CMP bean?)<BR>2) I can move my application written in DAO quicly in EJB without<BR>changing client code.<BR><BR>and so on.<BR><BR>But, if I am writing a new application, does it make sense use this<BR>schema? If so, what are the advantages?<BR>Thanks for your help in advance.<BR><BR>PS<BR><BR >if you have links talking about this use of DAO please let me know.<BR>(Do not send me mail of sites talking about general use of DAO).<BR><BR>=============== =====================================================<BR>Companion Site: http:/ /www.corej2eepatterns.com<BR>J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns<BR>List Archive:<BR>http:/ /archives.java.sun.com/archives/j2eepatterns-interest.html<BR>Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to<BR>listserv@(protected)<BR><BR>====== ==============================================================<BR>Companion Site : http://www.corej2eepatterns.com<BR>J2EE BluePrints: http://java.sun.com /blueprints/corej2eepatterns<BR>List Archive: http://archives.java.sun.com /archives/j2eepatterns-interest.html<BR>Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)</BLOCKQUOTE><BR><BR><P><FONT face=Verdana color=gray>huy.nguyen</FONT></P> <P><FONT size=1><FONT face=Verdana color=darkred>(t)<FONT color=#000000>+612 9271 3241</FONT> </FONT></FONT><FONT size=1><FONT face=Verdana color=darkred>(e ) </FONT></FONT><A href="mailto:d_huy_nguyen@(protected)"><FONT face=Verdana color =blue size=1>d_huy_nguyen@(protected)</FONT></A></P><p> <hr size=1><font face=arial size=-1>Do you Yahoo!?<br>Friends. Fun. <a href="http://messenger.yahoo.com/">Try the all-new Yahoo! Messenger</a> ==================================================================== Companion Site: http://www.corej2eepatterns.com J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
|
|
 |