Questions on DAO design

This is the first time I used DAO design.
I have a machine class and each machine has a few parts.
How should I design the DAO? Especially regarding the inner parts.
Should I create a DAO for machine and for part and put the PartDAO as an atribute of MachineDAO so that I can populate the Machine's parts with the help of PartDAOOr is it better to retrieve the parts directly when retrieving machine by JOINING the 2 tables (inside MachineDAO).
Or are there other best practices regarding DAO design?
Please help me,
Thx in advance,
David Limanus

Right sorry. When you think from the user of the DAO
yes, one DAO should deal with one object. Then when
you start implementing the DAO, You will try to
reduce the overall number of tables. I don't agree - the number of tables should be designed according to the data's needs and normalization rules, and the objects according to the problem's needs. Then you map one to the other. I don't understand what you mean by "reduce the overall number of tables".
But its true
that I may have 3 different DAOs that access the same
table. Meaning that one may access the table directly and others JOIN to it? Yes.
Also, that I have one DAO that uses multiple tables.Meaning JOINs? Yes.
Actually what I tried was to handle one table from
one class file. That didn't really work
either because of the joins and subqueries.
Inefficient by design: suffers from the (n+1)query
problem.Could you explain that problem? It seems to work
well for me and is easily managed.If you measure the performance and find that it meets your service level agreement, then it "works". But it depends on the number of Parts a Machine has, right? If you do one query for each Part, that means one network roundtrip for each one. As the number of Parts gets large, so does the number of network roundtrips. Since network latency is one of the biggest bottlenecks in your app, the more of them you do, the worse your performance.
A Machine that requires a small number of Parts might perform fine, but if the number increases you might find that performance is unacceptable. Maybe yours is "working well" because your Machines are simple.
%

Similar Messages

  • DAO design pattern & Transaction boundaries

    I am using a tool to generate a JDBC tier that applies the DAO design pattern. However, the generated code is based on "autocommit"-strategy, i.e. there is no conn.setautocommit(false)-statement in the code.
    I have added statement so that I can handle the transaction by myself. The DataAccessObject-implementation class does however close the connection before returning. I would like to execute the commit outside of the DAO-implementation.
    Anyone who have been experiencing the same problem?
    Best regards
    Lasse Bergstr�m

    I'm not sure if I fully understand your question.
    However, we usually implement such a scenario by doing autocommit false on the connection object and then passing it to the DAO. Finally do a commit on the connection in the calling class.

  • Questions about DAO

    Hi,
    we have some questions about DAO, Someone knows the answers?
    In versión 10g, one could create DAOs (Data Access Objects) from DB and then they could use them for extract and store data.
    In BPM 11g, how one could store information in the DB? How can they integrate them?
    Thanks in advance
    Antonio

    In 11g Database Adapters are used for direct access to the database. You add a DB adapter reference to your composite then this gets exposed as a service that can be invoked from the BPMN/BPEL process.
    Some documentation can be found here:
    http://download.oracle.com/docs/cd/E14571_01/integration.1111/e10231/adptr_db.htm#BGBBHJGC

  • Struts using DAO Design Pattern ..?Please give an example..... URGENT......

    Dear all,
    I have to develop an application in Struts by using DAO design pattern ..........
    Please give an example on Struts using DAO...................
    Thank you
    Please

    I'm glad you asked. It means Read The Flaming Manual. That'd be the struts manual by the way.

  • Struts using DAO Design Pattern Tutorail

    Can anybody give me a link for the Struts using DAO Design Pattern tutorial
    sample tutorial

    http://javaboutique.internet.com/tutorials/ApacheDAOs/
    Found by using google: strust dao pattern tutorial
    There are more good links using that search...

  • DAO Design pattern

    Hi,
    what is the advantages of DAO Design pattern over other design patterns?
    Can anybody tel me

    valooCK wrote:
    NANDA wrote:
    Hi,
    what is the advantages of DAO Design pattern over other design patterns?
    Can anybody tel methe answer is none!
    DAO stands for data access object, it is a non oo pattern, oo is data centric, it makes sense for data to access data. it is something created by poor procedural minds who can never understand what oo is.
    you may occasionary use it as a collection of functionalities or utilities, but thou shalt never use in as a pattern in oop!There are as-yet undiscovered tribes living in the Amazon, who knew you were going to say that
    @OP: Please ignore this troll, he doesn't even understand the very basics of OO, as can be demonstrated in the following thread
    http://forum.java.sun.com/thread.jspa?threadID=5273397&tstart=0
    Just ignore him. He only wants attention. He hasn't got the faintest idea how to write even "Hello World", let alone actually do any OO design

  • How to generate report from two tables using DAO design pattern?

    Hi,
    Iam using struts with DAO pattern for my application. According to DAO design im creating model class for each table in my database with getter,setter methods. i have no problem when im generating report from one table. but if have i have to join two tables whatis the better way for doing that? is it good practise to create a new model contains properties from both the tables?
    Please help me
    Thanks in Advance
    Rajesh

    Dear Rajesh,
    As per the pattern you are creating equivalent java objects for every database table under consideration in which each db field will become a private attribute and public getter and setter methods.
    If you have to display data from one table the above approach is sufficient enough.
    But in case your database is normalised ..lets take an example of Bank having Branch and Accounts tables. We dont need to repeat the whole information of the branch for every account in that branch. so we prefer to have a branch id in that table....this approach lot of insertion/deletion/updatation anomlies that may exists with the database...
    now lets come back to our topic....we shall create two java objects 1) Branch 2) Account.....
    When ever u just need to display simple report u can do it staright forward,,,,,now if u want to display branch information along with the account information....the two objects just created are not sufficient
    So i suggest u the following approaches
    1) Create an attribute of type Branch in the Accounts Object......
    This shall serve the purpose of displaying the Btranch information
    2) Create a collection object of type ( Vector or ArrayList) which can have objects of Account in the Branch Object,,,
    Now its upto u how shall u fill up the objects with appropriate sql queries.
    The method that i mentioned is followed by Oracle Toplink and Hibernate ....which provide Object to relation mapping layers.
    Any queries ...revert back to me...
    Mahesh

  • Question about singleton design

    Hi all
    i have a question about singleton design. as i understood it correctly, this pattern garantees us a single instance of a class at any time. in a environment of concurrent access(multiple user access at the same time) , does this single instance put a constraint on concurrency(singleton == synchronization)? i have developed a service object that reads in properties and constructs some other objects. the reason i made it singleton is that i only want this service object to load the properties once. and when it is called to create other objects, it always has one copy of the propertis. making this service singleton, will it limit the threads to access it and construct other objects? thanks for your help.

    If there's no write access to the HashMap, then
    you're thread safe.You were probably typing at the same time as the previous post, which explicitly says there IS write access to the HashMap.
    I don't know what it is, but people seem to have this magical view of concepts. Singleton is just what it is. It doesn't have a magical aura that causes other things to behave differently. A singleton is just Java code that can have thread safety problems just like any other Java code. So to the OP: forget about the fact that this is a singleton. That's irrelevant. Ask if a method needs to be synchronized.
    (And yes, a method that tests if a variable is null and assigns an object to it if it isn't null does need to be synchronized if it's going to have multiple threads accessing it.)

  • Help on Factory DAO design... S.O.S.

    Hi
    I have to develop a J2EE application and I have a theoretic question about Factory DAO pattern.
    Consider the following scenario:
    - I have to use a DAO patterns.
    - My database have 120 tables approximately.
    - The system have 20 logical modules approximately the can use whichever table.
    - I associate a Session Bean with Factory DAO class.
    1.- Do I have to implement only one Session-FactoryDao for all the system or one Session-FactoryDao for each logical module.
    2.- Can my session contain only one FactoryDao or many FactoryDao (that�s correct?)
    3.- I implement only one interface (implClassDao) for the FactoryDao class. Is possible implement many interface for the FactoryDao class?
    4.- What design strategy I have to follow?
    Thanks and I hope yours answers.
    Isra.

    Implement one factory for each of the logical modules. This is an advice and strictly an advice. There are more than one way of doing the same thing correctly - I feel the above is the right way, given your situation.
    Ironluca

  • Questions about DAO pattern

    Hi,
    I am a junior programmer and I am trying to understand somewhat more about best practices and design patterns.
    I am looking for more information regarding the DAO pattern, not the easy examples you find everywhere on the internet, but actual implementations of real world examples.
    Questions:
    1) Does a DAO always map with a single table in the database?
    2) Does a DAO contain any validation logic or is all validation logic contained in the Business Object?
    3) In a database I have 2 tables: Person and Address. As far as I understand the DAO pattern, I now create a PersonDAO and an AddressDAO who will perform the CRUD operations for the Person and Address objects. PersonDAO only has access to the Person table and AddressDAO only has access to the Address table. This seems correct to me, but what if I must be able to look up all persons who live in the same city? What if I also want to look up persons via their telephone numbers? I could add a findPersonByCity and findPersonByTelephoneNumber method to the PersonDAO, but that would result in the PersonDAO also accessing the Address table in the database (even though there already is an AddressDAO). Is that permitted? And why?
    I hope someone can help me out.
    Thanks for your time!
    Jeroen

    That is exactly what I am trying to do. I am writing it all myself to get a better understanding of it.
    Please bear with me, because there are some things I dont understand in your previous answer.
    1) Each BO validates his corresponding DTO and exposes operations to persist that DTO. Each DTO will be persisted in the database via his corresponding DAO. So this would be:
    - in PersonBO
    public void save(PersonDTO personDTO) {
    this.validate(personDTO); // does not validate the nested address DTOs
    this.personDAO.save(personDTO); // does not save the nested address DTOs
    - in AddressBO
    public void save(AddressDTO addressDTO) {
    this.validate(addressDTO);
    this.addressDAO.save(addressDTO);
    Am I viewing it from the right side now?
    2) Imagine a form designed to insert a new person in the database, it contains all fields for the Person DTO and 2 Address DTOs.
    How would I do this using my Business Objects?
    This is how I see it:
    // fill the DTOs
    daoManager.beginTransaction();
    try {
    personBO.setDao(daoManager.getDao(PersonDAO.class));
    personBO.save(personDTO); // save 1
    addressBO.setDao(daoManager.getDao(AddressDAO.class));
    addressBO.save(personDTO.getAddress(1)); // save 2
    addressBO.save(personDTO.getAddress(2)); // save 3
    daoManager.commit();
    catch(Exception e) {
    daoManager.rollBack();
    If I insert the transaction management inside the DAOs, I can never rollback save 1 when save 2 or save 3 fail.
    It can be that I am viewing it all wrong, please correct me if that is the case.
    Thanks!
    Jeroen

  • Question about Wireless Design and Controller

    Hi Everyone,
    Although I am not new to Cisco, I have somewhat limited experience with Wireless in general.  I was hoping to get your help with the following:
    We currently have a total of 8 1130AG, 4 on each floor.  They were configured a few years ago, and now we are looking to update the design a bit.  Each AP has its own SSID, and just provide internet access.  Looking at the configuration, I noticed that they are not configured to use proper channels, just random channels (9, 10, 11, instead of 1, 6, 11, etc.).  I noticed that when I roam between one AP to another, I lose about 4-8 pings before I re-establish connectivity again.
    Here are my questions:
    1.  Do I need a controller in order to use just one SSID for the whole setup instead of the 8 seprate ones we currently have?
    2.  Will the controller helps in providing seamless transition when a client roams between AP's?
    3.  Is it normal to loose connectivity roaming around?
    4.  Can I reconfigure the current setup to use just one SSID and provide better transition between AP without the use of a controller?
    5.  Which controller would you recommend?
    We don't have a need to anything fancy ,I am aware that I can enable multiple SSID, VLAN's, etc.  Just trying to keep it as simple as possible, yet reliable.
    Your input is appreciate.
    Thanks

    1.  With 8 AP's only, a WLC would be nice-to-have but not necessary. You can configure WLSE and it will do some limited functions.
    2.  This depends on the signal strengths, wireless coverage and configuration.  If you enable WLSE, for instance, and you have no wireless black spots, then roaming should be no issues.
    3.  See #2.
    4.  You can configure multiple SSID (up to 16 are broadcasted) but if one AP doesn't have the SSID you use for roaming, the association will drop when the client tries to join that particular AP.  It's like mobile phone towers.  If your carrier is not in the area, you sure won't be able to use your mobile phone in that area.
    5.  For 8 1130 APs, I'd recommend the smallest of the lot:  2106 with either 6, 12 or 25 AP licenses.  I'd recommend you the 25 AP licenses.  If your finances allow you something bigger, then consider either the 4402 (25 AP licenses) or the 5508.
    Cisco 2100 Series Wireless LAN Controllers
    http://www.cisco.com/en/US/prod/collateral/wireless/ps6302/ps8322/ps7206/ps7221/product_data_sheet0900aecd805aaab9.html
    Cisco 4400 Series Wireless LAN Controllers
    http://www.cisco.com/en/US/prod/collateral/wireless/ps6302/ps8322/ps6307/product_data_sheet0900aecd802570b0_ps6366_Products_Data_Sheet.html
    Cisco 5500 Series Wireless Controllers Data Sheet
    http://www.cisco.com/en/US/prod/collateral/wireless/ps6302/ps8322/ps10315/data_sheet_c78-521631.html

  • Hey guys, I have a question about Web Design

    I have been trying to learn webdesign for a few months now, and so far, I am still learning HTML and some CSS. At the moment, my experience is still very thin, I am struggling with things, and I only know how to create simple, static pages. For example I still don't know how to produce "clean code". Or how one determines just how "clean" the code he has produced really is.
    I was wondering if someone could answer a few questions I have:
    I am still not sure how I will know when I am competent enough to work in Web Design... What are the best signs that an individual is good enough?
    I was also wondering what programming language I need to know to do the following:
    Create a WORKING Site Search. One like the search bar in the top corner of this page that will return search results from your website... Do I need to know how to program PHP? I've heard that you do need PHP to do this? The same goes for creating e-mail forms, and other forms like this. Do I need PHP for this?
    Another thing is CMS systems like Wordpress and Joomla. What is the reason for using these as opposed to just designing a website's pages in Dreamweaver, and then uploading them via FTP to your web server?
    And finally, can someone explain to me why CSS is groped like this when it is coded? Why has the Div ID "OuterWrapper" been styled multiple times?
    For example: #outerWrapper #feature {
    #outerWrapper #subcontentWrapper {
    #outerWrapper #subcontentWrapper #rightColumn {
    ^ Couldnt the designer simply have styled "~OuterWrapper" once and left it at that?
    Please see below:
    #outerWrapper #feature {
        height: 225px;
        width: 880px;
        margin-left: 0px;
        margin-bottom: 5px;
        background-image: url(images/feature.jpg);
        background-repeat: no-repeat;
        background-position: center top;
    #outerWrapper #subcontentWrapper {
        padding-right: 15px;
        padding-left: 15px;
        clear: both;
        padding-top: 20px;
        background-color: #FFF;
        padding-bottom: 40px;
        border-top-width: 4px;
        border-right-width: 4px;
        border-left-width: 4px;
        border-top-style: solid;
        border-right-style: solid;
        border-left-style: solid;
        border-top-color: #F90;
        border-right-color: #F90;
        border-left-color: #F90;
        background-image: url(images/footer-fade.jpg);
        background-repeat: repeat-x;
        background-position: bottom;
        height: 100%;
    #outerWrapper #subcontentWrapper #rightColumn {
        float: right;
        width: 220px;
        background-color: #DBE7FB;
        border: 1px solid #DCDFE4;
        margin-bottom: 15px;
    Also, regarding Javascript: How exactly does one become proficient enough to learn scripting for the thousands of little widgets, and navigation bars, and other functions that Javascript can do out there?
    I know a lot of these questions are strange and may be hard to answer, but I am really hoping some of you guys can provide some helpful advice/direction for me to improve with code. I studied as a Print Graphic Designer, and now it's really hurting me in this economy trying to find a job due to the fact that I lack full competency in Web Design... and the longer it takes me to get better at this, the slimmer my chances become at finding work!
    I really need help on this, so I would be extremely grateful for detailed and informative answers. Perhaps some links to very good video tutorials on learning how to effectively design webpages - Common things like Javascripted navigation bars, image slideshows, how to design working site search forms and contact forms, and how to use Wordpress. I ask this because there are so many terrbile tutorial videos out there (I know from experience) and it is next to impossible for myself, a beginner, to tell the good ones from the bad.
    Thankyou guys.

    CMS's like  WordPress, Joomla! & Drupal are popular open source (PHP & MySql) frameworks.  They contain all the backend PHP code needed to create a dynamic web site that contains capability for advanced functions:  site search, on-line editing, shopping carts, member log-in sites, blogs with comments, scripted contact forms, and so much more...
    The allure of Open Source frameworks is that they save developers time and money.  Instead of building everything from scratch (which can take months), an experienced developer can usually install WordPress on the client's server and be up & running in a few hours without customizations, or in a couple of weeks with customizations.   A firm understanding of PHP, how to set up a server-side database, backing up MySql, CSS theming, and HTML code are required skills to work with these frameworks.  WordPress is probably the easiest to set-up; Drupal is for more experienced coders.
    I am still not sure how I will know when I am competent enough to work in Web Design... What are the best signs that an individual is good enough?
    You're ready when you can look at code and understand what it means/does. Being able to problem solve, identify mistakes and fix them on your own is a must have skill. 
    Code Tutorials - http://w3schools.com/
    How to Develop with CSS?
    http://phrogz.net/css/HowToDevelopWithCSS.html
    CSS positioning in 10 Steps
    http://www.barelyfitz.com/screencast/html-training/css/positioning/
    Code Validation Tools
    CSS - http://jigsaw.w3.org/css-validator/
    HTML - http://validator.w3.org/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • A question on component design in Web Dynpro

    Hi experts,
    We currently working on our console which we want to implement them using Web Dynpro framework.
    During design time,  questions have been raised: we have like 100 EJB methods for our application, about 8 EJBs, we want to have faceless component taking care of persistence.
    The question is what is the best way to distribute the methods in terms of performance and supportability (for ease of development )? We discussed the following options:
    1.     One faceless component with one component controller implements 100 methods (maybe this is the worst)
    2.     Many faceless components, one for each EJB, here the question came up: performance because we have a tab strip in the UI that accesses 6 EJBs, would it take a long time to load/unload these components every single time we switch among the tabs ?
    3.     One faceless component with one custom controller for each EJB, here the question is: can we expose the custom controller in other to use them in the tabs?  Compared to option 1 we clearly separated the methods, so it is easier to support. Furthermore we should have a performance gain since the custom controllers are only loaded on demand.
    What do you think?
    Regards,
    Dat
    Edited by: Dat Triet Banh on Jul 4, 2011 4:47 AM

    Hi
    Better to segregate the EJB's and put it in seperate controller keep atmost 30 in one controller (you have around 3-4 component ). Any component which is going to use in other component is basically based on create on demand priniciple automatically by framework.
    or
    as given in point third create a component , with say 8-10 Custom Controller  implement the all the methods and put a same method signature in Component Controller, call the same through interface thats it.
    Best Regards
    Satish Kumar

  • A few questions about the design of the scheme

    Hello, all!
    I want ask some question about design of the scheme.
    1) If i store info about user (for example: /Smith/Bob - /phone values{+1 964 258 46 52}), i can request information by user (input parameters: /Smith/Bob - /phone, output:+1 964 258 46 52), but if i want get username by phone i must generate in store second string /19642584652 values{Smith Bob}. But I must duplicate any string - very prodigally. Are existing some work aruond?
    2) if i want store some string with different minor key i put: ( /Smith/Bob - /phone, /Smith/Bob - /image, /Smith/Bob - /adress), but i already get duplicate date. Are existing any compressin major`s key? If yes - how it works
    3) Are existing in Oracle NoSQL something like secondary index? If exist - how it works?
    4) If i want get value by major key, im use get function(for example /Smith/Bob - /phone). How works searching algoritm? What mathematical basis of search?

    >
    So, some a few clarifying questions.
    1) Request comes from the client(to cluster). It identifies the major key. And any rep group understand: contained in it is this line?
    2) If contains - they use b-tree map to find the right key (as local index in Oracle DB).
    Is it correct?
    >
    No. Please read the doc and the other forum threads. They explain this issue.
    >
    Can i use any different algoritm to search, different indexes(function based) for example (on step 2)?
    >
    No.
    when the expected release of this option?Oracle employees cannot talk about future release dates and contents.
    What algorithm used to compress the prefix of the key. And how it work`s.If you're interested in the implementation details you can read the BDB JE documentation on key prefixing and the BDB JE source code. See com.sleepycat.je.DatabaseConfig.setKeyPrefixing.
    http://docs.oracle.com/cd/E17277_02/html/index.html
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Question about uploading design file when converting a html file to a master file in SP2013

    http://msdn.microsoft.com/en-us/library/jj822370%28v=office.15%29.aspx
    Here there is a note saying "When you upload your design files, you should keep all files that are related to a single design in their own folder in the Master Page Gallery. When you copy your design folder into the mapped network drive, the Master
    Page Gallery retains whatever folder structure you created."
    What do they mean keeping in own folder in Master Page Gallery?  All my design related files are in a single folder containing sub folders of images, css, js..  I copy this top folder to the http://ou.domain/_catalogs/masterpage/    
     This is also where I would copy my html file to first before converting to master file?
    Thank you.

    So I mapped to the server drive,
    http://our.domain/_catalogs/masterpage/    successfully.
     All my design related files are in a single folder containing sub folders of images, css, js..  I should copy this top folder
    to thehttp://ou.domain/_catalogs/masterpage/ 
        and also copy my html file to first before converting to master file.  My question is do I copy all these files(including the html file to be converted to master) to that masterpage folder before following the instruction to go to SP site
    setting and select and convert the html file?  Or is there any other steps I should or shouldn't do.
    Thank you.

Maybe you are looking for