Tight Coupling DAO with DTO

Hello All,
I need to ask a question about the DAO design pattern, does its CRUD methods have to be passed/return DTOs that encapsulates the domain data OR this data can exist as instance veraiable in the DAO class, and the client (session bean for example) can call the fine-grained set/get methods on the DAO.
I'm worried about tight coupling my DAOs with DTO as the DTOs will be custom/use case specific DTOs that don't necssary map to the domain DTOs.
Thanks

Stop cross posting! http://forum.java.sun.com/thread.jsp?forum=425&thread=497475&start=0&range=15#2349469

Similar Messages

  • 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/ 

  • Using DAO and DTO, or changing Patterns

    I have been working on a web project that revolves around scheduling events and enrolling people is said events. The schema is fairly straight forward, but does not lend itself well to OO, or at least what I have been used to. Before I get to the questions, I'll layout the basic idea of the trouble part of the schema.
    An Event has a 1:m relationship to Time Slots.
    A Time Slot has a 1:m relationship to Participants.
    A Time Slot also has a 1:M relationship to Tables.
    So, a given Event can run in multiple Time Slots, have multiple Participants in a Time Slot, and occupy multiple Tables in a Time Slot.
    Now, here's where I'd love some input because I know I'm lacking the experience. I've been reading in the forums here and in my books, many of which are included in the "must have" category as I've been reading here. I've adopted the DAO Pattern with DTOs the encompass the Event as a primary object/class. It has Lists which will get populated with the children. However, technically the way the schema is modelled, you cannot have participants or tables without a time slot. So, would I create separate bean or DTO to model the time slot that would also contains Lists for participants and tables? I imagine trying to represent nested relationships like the to a business layer might get hairy to maintain.
    So, in one scenario, an administrator would like to update event details, I'd use a findById() method to retrieve the full depth of the relationship in the schema.
    In a second scenario, a report is needed to list events, their times slots and tables in each time slot. Now, I have a List in my DTO that really has no need to be populated and would be wasteful to bring back from the database.
    A third scenario is a user comes to the site and wishes to search for events that they could enroll in. This time, for the search, I just want a few pieces from the primary table to displayed, I don't want to get the whole of the nested relationships and I want to get the search results by time slot. So, the way I've modelled the first DTO is now pretty much useless.
    So, is it better to construct to separate DTOs? I know I'd need different find() methods to support scenario 1 and 3. And in the case of retrieving non-needed data in scenario 2, should I provide a way to tell the DAO not to retrieve participants or just create yet another find() method that just doesn't populate participants?
    While I do have a say in the schema, I cannot just up and change it. I am more than willing to hear any and all critiques on code, schema, and how any part of this is implemented. As far as questions to why I'm not using Spring, Hibernate, or X framework, I just haven't had time to review them, but as this is still in design, it's fair game.
    Thanks in advance.

    >
    So, in one scenario, an administrator would like to
    update event details, I'd use a findById() method to
    retrieve the full depth of the relationship in the
    schema.
    In a second scenario, a report is needed to list
    events, their times slots and tables in each time
    slot. Now, I have a List in my DTO that really has
    no need to be populated and would be wasteful to
    bring back from the database.
    Ok - so don't do it.
    A third scenario is a user comes to the site and
    wishes to search for events that they could enroll
    in. This time, for the search, I just want a few
    pieces from the primary table to displayed, I don't
    want to get the whole of the nested relationships and
    I want to get the search results by time slot. So,
    the way I've modelled the first DTO is now pretty
    much useless.
    You can have more than one DTO. Or just don't populate everything in some cases.

  • DAO and DTO

    In the following piece of code:-
    package com.informit.myejb.dao;
    public interface SampleDAO
    public SampleModel create( long id, String name, String data ) throws
    SampleDAOException;
    public void delete( long id ) throws SampleDAOException;
    public void update( long id, SampleModel model ) throws
    SampleDAOException;
    public SampleModel[] findByName( String name ) throws
    SampleDAOException;
    public SampleModel findById( long id ) throws SampleDAOException;
    }we are creating a DTO named sampleModel. Now considering that I just need one value out of the whole table. Wouldn't creating the whole DTO object be a waste of time effort and memory, specially if each time we hae to access the DTO we have to create a new one. specially if the keys being passed to the method are used only once.
    I understand the concept of separation of concerns but I am concerned over here about the amount of effort required to create these DAOs and DTOs specially in cases where only one or two fields are required.
    To me it seems like an over kill.
    Any comments.

    well Martin Fowlwer does propose IdentityMap pattern in such a case where he says that thes objects should be stored in a Map with the primary key being the key for the map. So next time you need an object you check with the map if it exists or not and if it doesnot you try to grab it again.
    But IMHO if the hit ratio(no. of times the same data is used again) is less these Maps might pose a nightmare in terms of memory and garbage collection.
    So should one use IdentityMap or avoid it?
    What do you think.

  • Any plan to support tightly coupled transactions across domains?

    Hello,
    is there any plan to support tightly coupled XA transactions across domains?
    Our application has a few global transactions that span multiple domains. One domain updates a record in the Oracle DB. Later on in the same transaction the second domain retrieves the same record. But because of the loose coupling, the second domain cannot see the changes made by the first domain.
    Thanks...
    Roger
    PS: In some cases the second domain is actually a WLS domain. Because the loose coupling is a limitation of the Tuxedo Domain Gateway and WTC uses GWTDOMAIN, one could assume that once Tuxedo supports tightly coupled transactions across domains, WTC would also support it.

    Hi Roger,
    We don't have plans at the moment to solve this problem, although if it is a major problem for you, I suggest you contact Oracle support and ask them to enter an enhancement request. In general most customer have separate databases for each domain or application, thereby not normally running into this problem. Also, changing this in Tuxedo doesn't necessarily mean it would be changed in WLS as they use different transaction managers and the problem is more than a TDomain protocol issue. But generally when we make enhancements like this we try to keep GWTDOMAIN and WTC on par with one another.
    Regards,
    Todd Little
    Oracle Tuxedo Chief Architect

  • 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

  • Java data types are tightly coupled or loosely coupled ?

    java data types are tightly coupled or loosely coupled ?

    Is this another interview question? If so, the answer you should have given is, "You, sir, have been smoking too much crack."

  • 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

  • Invoke web service with DTO

    Hey guys,
    I am quite new in using BPEL. My first test worked fine, but know I have an issue, which I can not solve. Invoking web services with a basic return value is no problem. I could also you a dto object including some basic variables in order to invoke the web service without having problems.
    But when I have a dto object as return value, I get the following exception.
    Could someone give me a hint to fix my problem...that would be great!
    Thanks alot!
    Sven
    <messages>
    - <input>
    - <carReserveRequest>
    - <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="in0">
    - <in0 xmlns="" xmlns:def="urn:TravelBooking" xsi:type="def:CarReservationDTO" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <carType>
    Mini
    </carType>
    <customerName>
    9
    </customerName>
    <customerPhone>
    9
    </customerPhone>
    <reservationEnd>
    2030-12-12T00:00:00.000+01:00
    </reservationEnd>
    <reservationStart>
    2029-12-12T00:00:00.000+01:00
    </reservationStart>
    </in0>
    </part>
    </carReserveRequest>
    </input>
    - <fault>
    - <remoteFault xmlns="http://schemas.oracle.com/bpel/extension">
    - <part name="summary">
    <summary>
    exception on JaxRpc invoke: trailing block elements must have an id attribute
    </summary>
    </part>
    </remoteFault>
    </fault>
    </messages
    Message was edited by:
    user606281

    Here is more information. Below are the relevant sections of the web service's WSDL which I am trying to call from BPEL:
    - <wsdl:message name="getNextIDResponse">
    <wsdl:part name="part1" element="ns0:getNextIDResponse" />
    </wsdl:message>
    - <wsdl:message name="getNextIDFault">
    <wsdl:part name="part1" element="ns0:SOAPExceptionFault" />
    </wsdl:message>
    <wsdl:message name="getNextIDMessage" />
    - <wsdl:portType name="GetUniqueIDPortType">
    - <wsdl:operation name="getNextID">
    <wsdl:input message="axis2:getNextIDMessage" wsaw:Action="urn:getNextID" />
    <wsdl:output message="axis2:getNextIDResponse" />
    <wsdl:fault name="getNextIDFault" message="axis2:getNextIDFault" />
    </wsdl:operation>
    </wsdl:portType>

  • DAO with JDeveloper

    Hello,
    I am totally new with DAO, I only know it a little bit theorically.
    I want to use it from JDeveloper. And my question is if it is possible to use it from JDeveloper without using ADF, Spring or Hibernate? Is possible to use directly?
    Thanks and regards.

    There will always be a need to change your database accessing layer if the table definition is changed - no matter what approach you take.
    What you can do though is abstract the other layers of your application from these changes by providing another layer that provides a more generic set of methods.
    And yes you can do this with JDeveloper, you'll just need to program that interface on your own - just like in any other Java IDE.
    JDeveloper however will make the development of the layer that does communicate with the database simpler for you by using either JPA or ADF BC.
    Your DAO layer can be a layer above those components.

  • Sender RFC adapter - Tight coupling to an SAP client

    Hi ,
    We are using a sender RFC adapter to receive a RFC request from SAP , process the request in XI and then send back a response to SAP.
    Our requirement is that , this request may come from different SAP clients(client 100, 130 , 200 etc). Looks like RFC adapter configured under a Business System in XI cannot listen to calls from multiple clients and works for only one client. We get dumps in SAP when invoking this RFC from other clients.
    Also i hear that the same program id cannot be used in two different RFC sender adapters, meaning i have to create a different RFC destination , create a different program id for each client in SAP.
    Is there a way around for this issue ?
    Thanks
    Saravana

    Hi Saravana,
    you may try a little workaround:
    configure your rfc adapter only with client 100
    and try invoking RFC from clients: 130 , 200
    on the client 100 first (with a dummy RFC on client 100)
    and then from this dummy RFC on client 100 you can start your standard RFC with your rfc adapter
    don't know any other way:)
    Regards,
    michal

  • Best practices for DAO with relationships

    Suppose I have have a relationship structure similar to this:
    School -> 1:M -> Classrooms -> 1:M -> Students -> 1:M TextbooksShould I have 4 DAOs? (SchoolDAO, ClassroomDAO, StudentDAO, TextBookDAO)...
    How would be the best way to insert a Student?
    Would I insert the Student from the ClassroomDAO (because I need to know the ClassroomID in order to insert a Student)? Or would it be better design-wise to insert a Student in the StudentDAO, and assume the correct ClassroomID has been retrieved before the insert?
    I guess this sounds a lot like an ORM tool -- we've tried to use Hibernate in the past but we're working against a large legacy database and we've had lots of trouble hooking hibernate up to it. We're trying to construct a nice DAO layer because the app is lacking a good one -- but I'd like to make sure we're following the best practices.
    Thanks, Kevin

    kp5150 wrote:
    Suppose I have have a relationship structure similar to this:
    >
    >
    Should I have 4 DAOs? (SchoolDAO, ClassroomDAO, StudentDAO, TextBookDAO)...Just noting that that doesn't seem realistic. Either the students own the books or the school does.> School -> 1:M -> Classrooms -> 1:M -> Students -> 1:M Textbooks
    If the first then a school system wouldn't track them. If the second then you need ownership in the database that reflects that.
    And students are not part of a class room but rather part of a class. Classes are held/scheduled in class rooms.
    Additionally best practices generally dictate that table names should not be plural unless they contain sets (plural of set) data.
    >
    How would be the best way to insert a Student?
    Would I insert the Student from the ClassroomDAO (because I need to know the ClassroomID in order to insert a Student)? Or would it be better design-wise to insert a Student in the StudentDAO, and assume the correct ClassroomID has been retrieved before the insert?
    Probably irrelevant. You could do one or the other or even both. In one case you have a class to which a student is added. In the other you have a student and add them to a class.
    I guess this sounds a lot like an ORM tool -- we've tried to use Hibernate in the past but we're working against a large legacy database and we've had lots of trouble hooking hibernate up to it. We're trying to construct a nice DAO layer because the app is lacking a good one -- but I'd like to make sure we're following the best practices.Huh?
    If you have a unrealistic datamodel (like the above) then that is the cause of problems, not a tool.
    But in a generic sense if you have the following
    A -> 1:M -> B -> 1:M -> C -> 1:M D
    Then that is easy for tools to handle.

  • Jabber/WebEx Connect SSO Questions

    I've got a few questions around exactly what needs to be done to get SAML working for our Connect accounts to successfully authenticate from Jabber for Windows, Mac, iPhone, and Android.
    We have both a Meeting Center and Connect account under WebEx using Loose Coupled Integration. Just this past week I enabled SAML for our Meeting Center accounts which went off without a hitch with the exception of Meeting Center integration with Jabber, which is now broken with a message about SSO enabled Meeting Sites not being supported (I think this would maybe be fixed if we had Tight Coupled Integration with our two account?).
    Anyway, my questions are...
    For Windows, I understand all clients will need to be reinstalled with the MSI argument for the SSO_ORG_DOMAIN switch I've read about, is that correct? Are there any other switches needed for the reinstall? 
    How will this work with the Mac and mobile clients? There's obviously no command line options to specify for the installations here, will they just know to kick over to my IdP for authentication once they see an email address that falls under an org with SSO enabled? If so, why does the Windows client need to be completely reinstalled and not just know to find the IdP from the Cloud Connect service like Meeting Center does with the Productivity Tools?
    We're just doing this for our Connect Web IM accounts, not attempting any sort of SSO with the phone accounts/UC integration yet.
    Any ideas on getting the Meeting Center integration into Jabber working again?

    I'd suggest posting your question over on the Jabber Pilot forum, as this forum is specific to Jabber Guest questions:
    https://supportforums.cisco.com/community/4551/jabber-pilot-support
    -jim

  • AppServer and Development using JBuilder7 EE

    It has been noted that it is possible to develop EE applications using JBuilder. Is a patch likely to be available for JBuilder 7 Enterprise Edition? If so, please advise on the approximate release date.
    Many thanks
    Nasser Matoorian

    Hi Nasser,
    I assume that your question is "How can I develop J2EE applications with JBuilder and deploy to AS 7?"
    If that's the question, then the answer is that we do not have a solution for tightly coupled integration with JBuilder as yet. A plugin is in the works for tight integration between AS 7 and JBuilder and is scheduled for early 2003.
    However, in the meantime, you can continue to develop apps with JBuilder and use Ant for assembly and deployment of apps. See the bundled samples for an idea on how to use Ant with AS 7.
    Thanks,
    - deepak

  • How to create loosely coupled transaction branches with DBMS_XA ?

    Hello,
    I use DBMS_XA to start several sessions in the same database instance participating a global transactions. The local transaction branches are tightly coupled.
    Do you know a way (Oracle 11.2) for the branches to be loosely coupled by using dbms_xa in one-only instance ?
    Best Regards,
    Gregory

    For non XA datasource create a JDBC Connection with data source class
    oracle.jdbc.pool.OracleDataSource
    For xa datasource create a JDBC connection with data source class
    oracle.jdbc.xa.client.OracleXADataSource

Maybe you are looking for

  • PO retrieve old price from info record

    Hi Experts, I have maintain 2 pricing condition in info record with different validity date. Why PO still retrieve price which is validity date was expire instead of the valid pricing? Thank you.

  • Thinkpad Twist- Hard Drive issues

    Hello all! I have a ThinkPad Twist that is still under warranty. A couple of weeks ago I got a 2100 HDD detection error . I am currently based in a rural part of Mexico for work (for a few months) and called into the US service center and they said I

  • Third Party PO "No direct postings can be made to G/L"

    Hi, I am not able to create a PO from a Sales order/Pur.Req. and receive this error message "No direct postings can be made to G/L acct. 401201 in CoCode 0015. Message no. ME038. The G/L account you entered is a control account. Transactions cannot b

  • HT1454 I need a car charger for my Apple Iphone 4 S, which is suitable please

    Hello everyone! I need some help please, I have a battery charger for my Iphone 4S for the outlet at home. I also do need a car charger for the mobile phone, which one will be suitable for my Apple phone, can anyone advice please? It is a pity that A

  • Aperture Upgrade Issues (since Snow Leopard Install)

    I upgraded the OS on my 2007 iMAC7,1 Intel Core 2 Duo 2.4 GHz to Snow Leopard a couple of months ago. Afterwards, when I tried to start Aperture, I got a message that my version of Aperture (1.5.6) was not supported under the new OS. So today, I went