BO and DAO coupling

My patterns aren't the strongest, so I'm looking for a little help here.
BO - Business Object
DAO - Data Access Object
TO - Transfer Object
I'm writing a web app, and I have a set of BO's that need to be persisted. Everything I read says that I should have a TO to pass to the DAO, but I don't see the point of that. I realize that it's supposed to be decoupled and all, but if I can make the assumption that, realistically, I'm only going to use this set of BO's with this set of DAO's, is there a point to using TO's? It just seems like an extra layer that is going to wind up being pointless. I'd rather just pass the BO to the DAO for the CRUD stuff.
Can someone please show me some reasons that I shouldn't do it this way? I don't want to be 6 months into this and say, damn, I wish I used TO's.
Thanks in advance.

It would probably depend a lot on how many objects there are and how complex they are.
Is this project going to be finished in two weeks and done by a single person? And it grow less than 10% a year. If yes then do whatever is easiest. The overhead of figuring out any application for a maintainance programmer will be far more than understanding the code. And extra layers will just complicate it.
On the other hand if it is going to take 6 months and 3-5 developers are working on it with two new revisions already in the works, then seperating it is probably going to be very cost effective.

Similar Messages

  • JSP, BEANS AND DAO best practice... (and a little of STRUTS & JSTL)

    Hi,
    Want to get your opinion on how to really use bean and dao in jsp pages.
    Imagine that you wants to display a news list on the jsp index page for example.
    You've got a dao with method getLastNews(int size) which returns a Collection of News beans. Then with jstl or struts you iterate ove the collection to display the news in a formatted way.
    Easy to build collection with scriptlets & co but not very clean...
    What is the best way to call my dao and its method with a tag whithout using scriplets ?
    Thanks

    Yes this is the solution i use when the collection is displayed alone in a jsp page, but how do you do this when you include this collection in a page, and if you have other collections in other parts of the page ? Is there a clean solution of doing this in the jsp page? For example:
    <sometag:loadmycollection name="list"/>
    <logic:iterate id="myCollectionElement" name="list">
    Element Value: <bean:write name="myCollectionElement" />
    </logic:iterate>
    I know that i can write my own tag by if there is an existing solution...

  • Tightly and Loosely coupled scenarios

    Hi Experts,
    Could you please provide a example for Tightly coupled and Loosely coupled scenarios from SAP Platform?
    How to do the below scenarios from SAP platform?
    1. Tightly coupled (Non-SOA):
        Business Services : I have to create RPC encoded style webservices.
        Business Process : I have to call other platform RPC encoded style webservices (More than 2 webservices).
    2. Loosley coupled (SOA):
        Business Service : I have to create Document literal style webserivces
        Business Process : I have to call other platform Document literal style webservices ( More than 2 webservices)
    Please provide the input to do the above scenarios from SAP platform and please inform me which tool/component I have to use do the scenarios.
    Thanks & Regards
    Sara

    Hi Sara,
    Can you please elaborate your question in detail .
    1) Web Services are always examples of loosely couples architecture, either its document style or RPC style and whether you are creating WS or consuming WS.
    Tightly coupled architectures were those whose business logic layer and presentation layer were tightly coupled and reusability or scalability was a problem
    If you have user interfaces involved in your business process, then you should go for CAF( Composite Application Framework) to define a business process using VC, WebDynPro or Adobe Forms as UI.
    If it doesn't involve any user interaction, then you can go for ccBPM of Netweaver-PI to automate the process.
    Regards,
    Piyush

  • Tightly coupled and Loosely coupled scenarios

    Hi Experts,
    Could you please provide a example for Tightly coupled and Loosely coupled scenarios from SAP Platform?
    How to do the below scenarios from SAP platform?
    1. Tightly coupled (Non-SOA):
    Business Services : I have to create RPC encoded style webservices.
    Business Process : I have to call other platform RPC encoded style webservices (More than 2 webservices).
    2. Loosley coupled (SOA):
    Business Service : I have to create Document literal style webserivces
    Business Process : I have to call other platform Document literal style webservices ( More than 2 webservices)
    Please provide the input to do the above scenarios from SAP platform and please inform me which tool/component I have to use do the scenarios.
    Thanks & Regards
    Sara

    Hi Sara,
    Can you please elaborate your question in detail .
    1) Web Services are always examples of loosely couples architecture, either its document style or RPC style and whether you are creating WS or consuming WS.
    Tightly coupled architectures were those whose business logic layer and presentation layer were tightly coupled and reusability or scalability was a problem
    If you have user interfaces involved in your business process, then you should go for CAF( Composite Application Framework) to define a business process using VC, WebDynPro or Adobe Forms as UI.
    If it doesn't involve any user interaction, then you can go for ccBPM of Netweaver-PI to automate the process.
    Regards,
    Piyush

  • How to set the gain and input coupling for each channel on a NI 4462 DaQ card?

    I've seen a few examples in how to set the gain for NI 4462, but none tell me how to chose the channel I wish to set this gain.  Also the same problem with input coupling
    Does anyone know how to set the gain and input coupling for each individual channel?
    Thanks,
    Hector
    LabView 8.5 Windows XP

    Hey Hector,
    http://forums.ni.com/ni/board/message?board.id=100&thread.id=1688
    This has a few examples of how to do that.  Let me know if you have further questions.
    Have fun!
    -gaving

  • How to use same transaction when calling CMP entity beans and  DAO (JDBC)

    We are currently using Weblogic 8.1 SP2 with an Oracle 10g database (using XA thin and non-XA drivers).
    We have a session bean that invokes an entity bean and a DAO (data access object pattern) in order to add data in 2 separate tables (account and history). Rows are added to the first (account) table using a CMP Entity bean while inserts are done in the 2nd (history) table using a DAO. Here is some pseudo code:
    addHistorySessionBean (trans-attribute="Required")
    begin
    Step #1 - call addAccountEntityBean (trans- attribute="Required")
    Step #2 - call addHistoryDAO (get datasource, connection)
    end
    The 2nd table (history) has a foreign key constraint to ensure that the corresponding key exists in the first (account) table. Unfortunately, DAO inserts on the 2nd (history) table fail with a foreign key constraint violation (INTEGRITY CONSTRAINT VIOLATION - PARENT KEY NOT FOUND!) since they cannot see the row added to the 1st (account) table in step #1 by the CMP entity bean.
    How does one ensure that all this is done in a single transaction ? It appears that the app server creates two seperate transactions (one for the session bean facade and the entity bean and a 2nd transaction (when we retrieve a connection using the same data source JNDI name) for the DAO.
    A post on server side suggested using a "<resource-ref>" in the session bean to tie the two potentially separate transactions together, but that does not work for us. However, I am not sure if we are doing that correctly. After we define the resource ref in the session facade bean, do we use the resource ref "name" attribute to lookup the datasource or do we still lookup the datasource by JNDI name ? Do we need to define the resource-ref tag in the entity bean also ?
    Does Weblogic allow using a single transaction for this type of a scenario ? How does one specify within Weblogic that the same transaction should be utilized by the entity bean and any subsequent DAOs?
    People have also suggested that we defer constraint checking until the transaction(s) are committed but that sounds like a work acount without addressing this issue. Would postponing the constraint checking in Oracle cause any additional overhead ?
    Any suggestions with specific examples or documentation on how to address this issue will be gratefully appreciated.

    Thanks for your suggestion. Unfortunately, this does not work since it appears that there are 2 separate transactions going on here. One, the original one initiated by the session bean and used by the entity bean and the other initiated by the DAO. Any other ideas appreciated.
    Hi,
    Try setting the delay-database-inserts tag to
    ejbCreate in RDBMS descriptor file.
    http://bernal/stage/wls/docs81/ejb/DDreference-cmp-jar
    .html#1113981
    vasanthi ramesh

  • Oracle ODBC and DAO extremely slow

    Hi
    I'm using Microsoft DAO 3.6 with an Oracle ODBC connection (version 9.2) in an VB6 application.
    Opening an updateable dynaset is extremely slow, I have measured the performance with Oracle ODBC, Microsoft Oracle ODBC and Microsoft SQL-Server ODBC as follows:
    Oracle ODBC: 1952 ms
    MS Oracle ODBC: 360 ms
    MS SQL-Server ODBC: 40 ms (connection to a MS SQL-Server)
    If I use the SQLpassthrough option the result is about 10 ms in all 3 cases, but the dynaset is readonly !
    The testing program is as follows:
    Option Explicit
    Private Declare Function timeGetTime Lib "winmm.dll" () As Long
    Private Sub Form_Load()
    Dim wsdata As DAO.Workspace
    Dim db As DAO.Database
    Dim dbconn As String
    Dim rs As DAO.Recordset
    Dim start As Long
    dbconn = "ODBC;DSN=AdhocitORA;UID=adhocit;PWD=adhocit;"
    Set wsdata = DBEngine.Workspaces(0)
    Set db = wsdata.OpenDatabase("", False, False, dbconn)
    start = timeGetTime
    Set rs = db.OpenRecordset("Select * from Afdeling", dbOpenDynaset)
    rs.MoveLast
    rs.MoveFirst
    rs.Close
    Set rs = Nothing
    MsgBox "Time " & timeGetTime - start
    End Sub
    Is there any setting in the Oracle ODBC, that need to be adjusted ??
    Erling

    Why are you doing a moveLast followed by a moveFirst? That's going to force Oracle to retrieve all the records in the recordset. If there are a lot of records, you'll probably see a benefit if you increase the prefetch in the Oracle ODBC DSN configuration.
    Justin

  • BUSINESS  DELEGATE PATTERN AND DAO

    Culd anyone explain me then with an example?
    Thanks in advance.

    SubjectDelegate subjectDelegate = new SubjectDelegate();
    //This is an example which shows that the form values are set in to a transfer object
    //and then through the delegate it calls the createSubject() method from ejb's
    // subjectVO.setSubjectName(createSubjectPMTLForm.getSubjectName());
    // subjectVO.set ........so on....
    subjectDelegate.createSubject(subjectVO);
    # This will call the method in the delegate(SubjectDelegate)...which will further delegate it to the next level.
    public void createSubject(SubjectVO subjectVO)throws Exception {
         try {
              getFacadeInstance();
              subjectFacade.createSubject(subjectVO);
         } catch (Exception e) { }
    # here facade is the stateless session bean which can be used to call entity bean to crete the record in database or a DAO
    I hope i did not confuse u much.........
    Some client----------> Delegate-------->Facade(Session bean)--------->EntityBean or DAO
    Reply with ur mail ID if u still did not understand how to use the delegate.
    Regards,
    Aru

  • WLS8.1 and tightly coupled transactions?

    I have the following scenarion that does not seem to work.
              1. A client calls a method in EJB1
              2. EJB1 inserts a row in a database
              3. EJB1 calls a method in EJB2
              4. EJB2 tries to read or reference the row inserted by EJB1.
              5. The database waits and eventualy an Exception is thrown.
              It seems as WLS treats the XA-transaction as loosley-coupled (see the XA-specification). The behaviour that I want is a tightly-coupled transaction, but that does not seem to be the case.
              - I'm using WLS8.1sp4
              - EJB1 and EJB2 are stateless session beans using CMT and default behaviour.
              - EJB1 and EJB2 uses different database pools.
              - I'm using Informix 7.31 Database and Informix JDBC XA Driver 2.21JC6
              Anybody that have any ideas about this?

    Hakan Waller wrote:
              > I have the following scenarion that does not seem to work.
              >
              > 1. A client calls a method in EJB1
              > 2. EJB1 inserts a row in a database
              > 3. EJB1 calls a method in EJB2
              > 4. EJB2 tries to read or reference the row inserted by EJB1.
              > 5. The database waits and eventualy an Exception is thrown.
              >
              > It seems as WLS treats the XA-transaction as loosley-coupled (see the XA-specification). The behaviour that I want is a tightly-coupled transaction, but that does not seem to be the case.
              >
              > - I'm using WLS8.1sp4
              > - EJB1 and EJB2 are stateless session beans using CMT and default behaviour.
              > - EJB1 and EJB2 uses different database pools.
              > - I'm using Informix 7.31 Database and Informix JDBC XA Driver 2.21JC6
              >
              > Anybody that have any ideas about this?
              I think the issue is that the data inserted in EJB1 is not available
              for anyone else to see until that EJB's transaction is committed.
              If EJB2 is defined so that it joins the same transaction, it should
              be able to see the not-yet committed data, but if it's a different
              tx, it shouldn't. However, how is EJB2 able to access the data via
              a different pool than the one used to insert the (not-yet committed)
              data?
              Joe

  • Cairngorm View Helper - Command resuability and tight coupling with view

    I am new to Cairngorm framework. Currently we are converting
    our project to Cairngorm framework. I have some very basic doubts
    regarding the framework. Basically I am a java/J2ee
    programmer and got very good experience in struts framework
    and other J2EE design patterns.
    I have some doubts and needs advice from the community .
    My very first doubt is regarding the ViewLocator pattern used
    in the Cairngorm framework to access
    the view from Command class. At a very high level my
    understanding about command pattern is that command object
    shouldn't know anything about the caller. Command should execute a
    the business logic and update the model.
    But if we use the ViewLocator pattern the command object
    should know about it's caller class and the method name of the
    view/viewhelper class which should be executed after the command
    logic. In this scenario we will not be able to reuse the command
    class and a very tight coupling is established between the command
    and view.
    I have read from flex and cairngorm related blogs about an
    'Observer' and 'ChangerWatcher' patterns which seems to be right
    approach for me rather than using the ViewLocator. But as far as I
    know these are not part of the framework.
    I would like to know what is the recommended approach from
    the cairngorm framework team for executing View related logic after
    firing the Cairngorm event.
    If we use the ViewLocator pattern, there is no reusability as
    far as the command is concerned and also a very tight coupling is
    happening with the command and view.
    Is this the right approach..?
    Please advice..

    Hi, the view Locator has very issues that we have to have in mind, y most of the  problems are similar when we are using the Drag Manager , when we are using modules and load this view dynamically.
    The solution is simple and you told it. Binding by Watchers in the model Locator and checking the model locator variables when we load a module.
    In the view that we want to change we can add a Change Watcher linking a model locator variable to a function in the view, we change the model in de command and automatically change the value in the view.
    There are 2 ways to do the same concept, but is good only when the call to a cairngorm only affects the view that its calling it and known more has to know, so in theory you don’t need to change the model to impact the view.
    First is adding a Iresponder in to the event by Get Set so in the view, when you create a event for cairngorm and have to pass through the event an IResponder  (mx.rpc.IResponder). When you are in the command in the result or fault you can do event.responder.result = event or event.responder.fault = event and this well go directly into the view result o fault. So you don’t have to pass through the model. (Responder is your get set in the Event of private var _responder:IResponder)
    The other way is the same but using UM cairngorm that has CallBacks. And it’s pretty much the same but the event and all the cairngorm has callbacks and notifyCaller.
    Well I hope I said something useful.
    I did a UM cairngorm diagram in English http://www.developyourdream.net/tutoriales/tutoriales_flex_avanzados/cairngorm_universal_m ind/Cairngorm.swf
    Sorry me English and if somebody talks Spanish you can go check my blog http://www.developyourdream.net/ 

  • Tranaction with KODO JCA and DAO

    Hi,Abe,
    I use KODO JCA with JBoss3.2.1.We encounter some problem with transaction.We use CMT(Container Management Transaction)provider by JBoss EJB container.
    the seniario is:
    public class SessBeanA iimplements SessionBean{
    public void method(){
    A a_new A();
    a.method1();
    B b_new B();
    b.method2();
    public class A{   _
    method1(){
    //use KODO jdo insert one record. _
    public class B{
    method2(){
    //use DAO query the record insert.
    method() inSessBeanA is configued use CMT and start new tranction when called.
    We want to keep a.method1() and b.method2() in same transaction(method1() and method2() use transaction created by method()).but unfortunately,as they use different DB connection instance(one is from KODO JDO JCA,the other is from direct JDBC),they didn't keep in same transaction.so b.method2() can't find the record insert by a.method1() because method1() hasn't commit.
    you know,as for complexity,we can't use only KODO for insert/query,we had to use other technology like DAO.Would you pls tell us how to keep KODO JDO call and our DAO call in same transaction?
    Regards,
    geduo

    Consider getting a database connection from Kodo using JDBCStoreManager,
    i.e.
    KodoPersistenceManager.getStoreManager().getConnection() or
    KodoPersistenceManager.getConnection() I think.
    Then you'll get the same connection Kodo is using and hence the same
    transaction associated with it.
    Alex.
    geduo wrote:
    This is a multi-part message in MIME format.
    ------=_NextPart_000_001D_01C3CF8B.2D85C0D0
    Content-Type: text/plain;
         charset="gb2312"
    Content-Transfer-Encoding: quoted-printable
    Hi,Abe,
    I use KODO JCA with JBoss3.2.1.We encounter some problem with =
    transaction.We use CMT(Container Management Transaction)provider by =
    JBoss EJB container.
    the seniario is:
    public class SessBeanA iimplements SessionBean{
    public void method(){
    A a=3Dnew A();
    a.method1();
    B b=3Dnew B();
    b.method2();
    public class A{   =20
    method1(){
    //use KODO jdo insert one record. =20
    public class B{
    method2(){
    //use DAO query the record insert.
    method() inSessBeanA is configued use CMT and start new tranction when =
    called.
    We want to keep a.method1() and b.method2() in same =
    transaction(method1() and method2() use transaction created by =
    method()).but unfortunately,as they use different DB connection =
    instance(one is from KODO JDO JCA,the other is from direct JDBC),they =
    didn't keep in same transaction.so b.method2() can't find the record =
    insert by a.method1() because method1() hasn't commit.
    you know,as for complexity,we can't use only KODO for insert/query,we =
    had to use other technology like DAO.Would you pls tell us how to keep =
    KODO JDO call and our DAO call in same transaction?
    Regards,
    geduo
    ------=_NextPart_000_001D_01C3CF8B.2D85C0D0
    Content-Type: text/html;
         charset="gb2312"
    Content-Transfer-Encoding: quoted-printable
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
    <META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
    <STYLE></STYLE>
    </HEAD>
    <BODY>
    <DIV>
    <DIV><FONT face=3DArial size=3D2>Hi,Abe,</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2>I use KODO JCA with JBoss3.2.1.We =
    encounter some=20
    problem with transaction.We use CMT(Container Management =
    Transaction)provider by=20
    JBoss EJB container.</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>the seniario is:</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
    <DIV>
    <DIV><FONT face=3DArial size=3D2>public class SessBeanA iimplements=20
    SessionBean{</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>    public void=20
    method(){</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>        A =
    a=3Dnew=20
    A();</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>       =20
    a.method1();</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>        B =
    b=3Dnew=20
    B();</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>       =20
    b.method2();</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>    }</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>}</FONT></DIV></DIV>
    <DIV><FONT face=3DArial size=3D2>public class A{    =
    </FONT></DIV>
    <DIV>
    <DIV><FONT face=3DArial size=3D2>    =
    method1(){</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>        =
    //use KODO=20
    jdo insert one record.    </FONT></DIV></DIV>
    <DIV><FONT face=3DArial size=3D2>    }</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2>public class B{</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>    =
    method2(){</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>        =
    //use DAO=20
    query the record insert.</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>    }</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2>method() inSessBeanA is configued =
    use CMT and=20
    start new tranction when called.</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2>We want to keep a.method1() and =
    b.method2() in same=20
    transaction(<STRONG>method1() and method2() use transaction =
    created</STRONG>=20
    <STRONG>by method()).</STRONG>but unfortunately,as they use different DB =
    connection instance(one is from KODO JDO JCA,the other is from direct =
    JDBC),they=20
    didn't keep in same transaction.so b.method2() can't find the record =
    insert by=20
    a.method1() because method1() hasn't commit.</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>you know,as for complexity,we can't use =
    only KODO=20
    for insert/query,we had to use other technology like DAO.Would you pls =
    tell us=20
    how to keep KODO JDO call and our DAO call in same =
    transaction?</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2>Regards,</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2>geduo</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
    <DIV><FONT face=3DArial size=3D2></FONT> </DIV></DIV></BODY></HTML>
    ------=_NextPart_000_001D_01C3CF8B.2D85C0D0--

  • Transaction problem with stateless EJB and DAO

    Hi,
    I'm using a stateless session bean with container managed transaction and I have a method, which updates a row via CMP entity bean and then calls stored procedure, using a DAO object, which has to use the updated data. Both calls must be done in one transaction. The problem is that the stored procedure doesn't see the changes made from the update via CMP EJB, but after the method exits the changes are in the database. I'm using WebSphere 4.0.3 and DB2 7.2. Method code example in the stateless bean:
    public doIt(ValueObject vo) throws ... {
    OrderPosRemote opr = getOrderPosRemote();
    opr.update(vo);
    getDAO().recalc(vo);
    } catch (DAOException daoex) {
    getSessionContext().setRollbackOnly();
    And in the DAO:
    public boolean recalc(...) throws DAOException {
    Connection conn = getConnFromDataSource();
    CallableStatement cstmt = conn.prepareCall("call ...(?,?)");
    cstmt.execute();
    ... // close cstmt and release connection to the pool
    Any help will be highly appreciated !

    Hi meadandale,
    this was my first guess too and I set this attribute in the session bean method, then into the update method of the CMP bean and "manually" to the connection object in the DAO like this:
    conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
    The isolation level is set correctly (IMHO), because when I comment the line above in the DAO, an exception is thrown stating that the isolation level can't be changed within a transaction.
    Unfortenully this didn't help too. Should I set some special attribute to the database or connection pool additionally ?
    I don't understand what is the problem actually - it is definitely one transaction and why this doesn't work is not very clear to me ...

  • DAO Pattern and the ServiceLocator

    I have been developing a lightweight framework for working with AIR and the SQL API. This framework has no dependencies on Cairngorm however it is built around a typical DAO implementation.
    While developing this I considered how it should be integrated with Cairngorm, which lead me to wonder if a simple DAO marker interface which could be retrieved from the ServiceLocator (and cast to the correct abstraction by a business delegate) would not be all that is needed to have a rather flexible service layer in Cairngorm?
    For example, consider the following pseudo code which is what I would imagine a business delegate to look like:
    class FooDelegate {
    protected fooDAO:IFooDAO;
    public FooDelegate(responder:IResponder) {
    fooDAO = ServiceLocator.getinstance().getDAO(Service.FOODAO) as IFooDAO;
    fooDAO.addResponder( responder );
    public getFoo() void {
    fooDAO.getFoo();
    public addFoo(foo:IFoo) {
    fooDAO.addFoo(foo);
    public deleteFoo(foo:IFoo) {
    fooDAO.deleteFoo(foo);
    As you can see the delegate would cast the dao to the correct abstraction and then just wrap the DAOs API (somewhat similar to an Assembler in LCDS).
    A custom DAO interface would extend the DAO marker interface so that the ServiceLocator could find it:
    interface IFooDAO extends IDAO
    getFoo() void;
    addFoo(foo:IFoo);
    deleteFoo(foo:IFoo);
    Service.mxml would define an instance of the dao as an abstraction and then call a factory to get the appropriate implementation:
    public fooDAO:IFooDAO = DAOFactory.getDAO("foo");
    I see much potential in this type of implementation as it would allow services to be swaped out with different implementations via a config or with an IoC implementation etc, thus allowing the services themselves to be completely transparent to client code.
    I wanted to see if anyone had any thoughts on this as well?
    Best,
    Eric

    Thanks, duffymo, that makes sense. However ... having read through numerous threads in which you voice your opinion of the DAO World According to Sun, I'd be interested to know your thoughts on the following ...
    Basically, I'm in the process of proposing an enterprise system architecture, which will use DAO as the primary persistence abstraction, and DAO + JPA in the particular case of persistence to a RDBMS. In doing so, I'd like to illustrate the various elements of the DAO pattern, a la the standard class diagram that relates BusinessObject / DataAccessObject / DataSource / TransferObject (http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html). With reference to this model, I know that you have a view on the concept of TransferObject (aka ValueObject?) - how would you depict the DAO pattern in its most generic form? Or is the concept of a generic DAO pattern compromised by the specific implementation that is used (in this case JPA)?

  • DAO pattern and Java Persistence API

    Hi
    This is a question for anyone who might be familiar with the standard DAO design pattern and the Java Persistence API (JPA - part of EJB3). I'm new to this technology, so apologies for any terminology aberrations.
    I am developing the overall architecture for an enterprise system. I intend to use the DAO pattern as the conceptual basis for all data access - this data will reside in a number of forms (e.g. RDBMS, flat file). In the specific case of the RDBMS, I intend to use JPA. My understanding of JPA is that it does/can support the DAO concept, but I'm struggling to get my head around how the two ideas (can be made to) relate to each other.
    For example, the DAO pattern is all about how business objects, data access objects, data transfer objects, data sources, etc relate to each other; JPA is all about entities and persistence units/contexts relate to each other. Further, JPA uses ORM, which is not a DAO concept.
    So, to summarise - can DAO and JPA work together and if so how?
    Thanks
    P.S. Please let me know if you think this topic would be more visible in another forum (e.g. EJB).

    Thanks, duffymo, that makes sense. However ... having read through numerous threads in which you voice your opinion of the DAO World According to Sun, I'd be interested to know your thoughts on the following ...
    Basically, I'm in the process of proposing an enterprise system architecture, which will use DAO as the primary persistence abstraction, and DAO + JPA in the particular case of persistence to a RDBMS. In doing so, I'd like to illustrate the various elements of the DAO pattern, a la the standard class diagram that relates BusinessObject / DataAccessObject / DataSource / TransferObject (http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html). With reference to this model, I know that you have a view on the concept of TransferObject (aka ValueObject?) - how would you depict the DAO pattern in its most generic form? Or is the concept of a generic DAO pattern compromised by the specific implementation that is used (in this case JPA)?

  • High Cohesion and a dash of Low coupling

    I have two classes.(well there more but i will use two to explain my problem)
    Items are processed one by one, by class1, as soon as an item is processed it is sent to class2 for futher processing. Class2 contains queues which stores items sent from class1 while they wait to be processed. I have implemented this, however my problem is as follows:
    There is a need for a 'routing system' class which recieves items (one at a time) from class1, works out the shortest queue lenght in class2 and then sends that item to that queue.
    The biggest probelm is that the class must be able to handle different situations. E.g able to handle any number of queues, etc.
    (Some may be thinking why don't you just write this as method inside class2. The answer is that this 'routing system' is going to be used by the whole program, so it must be made available to all classes without the need for)
    Basically High Cohesion and low coupling is the key and this is the reason why I find it difficult to implement this class.
    Can anyone help, Thanks.

    My suggestion would be to put a manager on top of the queue-set.
    So, for a given set of queues, there is a managing-thread that 'receives' the input (output from a prior op) and also responds to the dequeue operation. There are plenty of article on multithreading with multiple producers and multiple consumers. Just use a singleton for the manager.
    http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=Java+Multithreading+multiple+producers
    http://archive.devx.com/sourcebank/details.asp?resourceNum=123662

Maybe you are looking for

  • ITunes 11.4 bug when used with OS 10.6.8 - won't sync or backup iPhone

    I actually just wanted to post this in case Apple monitors these boards. iTunes 11.4 says it's compatible with OS 10.6.8 or later, but there is a bug in it when you're running OS 10.6.8 that prevents you from backing up or synching your iPhone (in my

  • How can I always display duplicate email messages in Apple Mail?

    I would like to have Apple Mail ALWAYS display "duplicate" messages without having to click on the duplicates link in the upper right of the message.  Apple Mail identified a series of messages as "duplicates" when in fact they were not duplicates. 

  • Iphoto 11 upgrading problems

    I just bought the new version of iphoto 11 and i installed it through the app store on my mac. When iphoto opened, it told me that i need to update my library because iphoto doesn't work with the previous version i had. I clicked update and it told m

  • Mac:word 04/08 random removal of spaces

    short: mac:word removes spaces from documents randomly. long: At first I thought it might be an issue with windows:word 2007 users and mac:word 04/08 users working on the same documents; however, I have had several instances were a mac:word 04/08 doc

  • How to install down load manager on windows

    Guys, Please let me know detailed process of installing download manager. whish java version i need to use? Thanks in advanace.