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.

Similar Messages

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

  • Have a used iPhone4 and need to change to former user ID ?

    I purchased a used iPhone4 and the former owner's Apple user ID keeps appearing when  attempting  to purchase via app store. How can I change this to my own ?

    Settings/iTunes & App Store tap on ID. And log out then log in with new.  You might also want to change ID in settings/messages and delete iCloud account in settings/ilcoud

  • I bought a Use IPad and need to  change my  ID

    Hello, I need help I have bought an used IPad' 3 @and need to change the old Apple ID to my own ID.   Please help me

    Yes you can as long as the previous owner erased the iPad according to these instructions. If the previous owner didn't do this, contact him or her and ask for their help. If the last owner cannot be reached or will not cooperate, you will eventually run into problems that you will not be able to resolve and you will have a useless brick on your hands.
    What to do before selling or giving away your iPhone, iPad, or iPod touch - Apple Support

  • At 60 and totally confused w/version . Not  clue with how to use it and how to change it. My question - If a new version of i-tunes can be offered why not the older version as being a choice? Too simple or just impossible to do? I hate to drop i-tunes.

    At 60 years of age and totally challenged by todays technology I find it impossible to understand i-tunes Version 11. Don' ask me to try to try go back to a earlier version ( as much as I would like to). I have read some of the advice given, as well as intended as it is, I don't understand the process. I don't want to drop i-tune but I will. I am sure my library is not as large as many others who use it but it is just as important to me. This really saddens me.
    I do have two question if some one can help me. First, someone mentioned that if I go to previous restore point this might correct it. Yes or no? Secondly, if Apple can offer us a new version to download why can't they offer an older version to download. Too simple or impossible to do.

    You can still drag and drop a song into a Playlist, in the same manner as before. Simply use the left-click of your mouse to select-and-hold the song (left-click-and-hold, don't release the click) and drag it to and then drop it (release the click) into the Playlist you want. (You cannot drop it into a Smart Playlist, you can only drop it into a Regular Playlist.)
    ... and here's a screenshot dragging the song "Lazy Orbit" into the Regular Playlist "Sat 4th June 2011". A small + symbol also appears in the drag, but it doesn't show up on screenshots. If the move is forbidden, a red slash through a red circle appears instead of the + symbol.
    As for the Albums thing; in the Column Browser, right-click anywhere in the Column Browser header (see my screenshots in my previous post) and a menu appears. Deselect Albums on that menu to remove Albums from the upper Columns:
    ... and for the columns underneath (with the songs list etc.), right-click on that header bar and once again, deselect Albums from the menu that appears. The Albums column will then be removed from the lower columns list.
    ed294 wrote:
    You would think with all the complaints they are getting they would want us, the buyers, to be satisfied with there product.
    Well, my advice to you is: do not think about what you think iTunes cannot do, instead, think about what you want to achieve - and then work out how to achieve it.

  • Use DAO or plain SQL?

    I am building a two-tiered enterprise app with Swing client and RDBMS backend. Over the last two weeks I've tried applying the DAO pattern to my design, manullay creating numerous DTO and DAO classes. I'm now starting to wonder if it's really worth the effort.
    My system is not complicated enough to justify the use of automated OR mapping tools or CMP. Also, the development staff on my team, including myself, have had no expereience in OR mapping and EJB; all we've done in the past involve simple application that accesses the database directly using SQL. We also feel that using SQL directly is adequate in implementing all the functionalities of our system.
    Our initial motivation for implementing DAO was to maximize reuse of persistence code, make code more readable and insulate UI/logic code from change in database schema. But it seems we're now spending too much time thinking about how to map database entities to DTOs, what DAOs to have, what DAO methods to define, etc., whereas in the past to get something from the database we could just write an SQL statement.
    TIA.

    I wouldn't do any application without using DAOs and
    DTOs.
    Perhaps you are focusing to much on the examples
    rather than on the pattern itself. Just because the
    examples do it does not mean that you have to do it.
    You can do with with just one infrustructure class (to
    do the connections, statement, etc) and then the
    following....
    class MyDTO
    public String field1;
    public String field2;
    class MyDAO
    static void create(MyDTO p) {...}
    static void update(MyDTO p) {...}
    static void delete(MyDTO p) {...}
    static MyDTO getById(String id) {...}
    static ArrayList getBySomethingElse(String
    somethingElse) {...}
    }And of course if you don't need one of the above
    methods then do not implement it.i have been doing almost everything in dao but i m not so sure why dtos are so essential, if you write your pojo well, dtos seem to be totally not needed; unless of course you are passing them across networks in ejb systems, and even that, theses days xmls are recommended instead. am i right?
    and lately i havee started using hibernate which i think is great even for small not complecated projects: it does not complicate things, and further, you can still do things in dao with hibernate, i dont see any conficts there: hibernate, jdo are mostly mapping mechnism, and dao is a design pattern.

  • How can I create an action that uses "Find and replace"?

    Hi there,
    I'm trying to create an action that will use "Find and replace" to change certain words and phrases in my .psd-files. These are words and phrases I change a lot (I'm translating emails and website banners) and I would like to speed up that process using actions.
    When I tried to create the action I got the error message "The object "in contents of all text layers" is not currently available".
    Then I tried "insert menu items" and chose "Find and replace" and then did my change, but then it stopped when the FAR-window popped up. That's what I want to skip, so it just changes my words and phrases that I want.
    Is this possible?
    Best,
    Carl

    Anyway, in the Script in that other thread the function replaceText takes two Strings, so something like
    function main () {
    var myDocument = app.activeDocument;
    replaceText ("replace this", "with this")
    would be a possibility.

  • Help needed. I have a 3TB external hard drive partitioned into 1TB's. I used one partition as backup for the main computer hard drive. But now it is greyed out as shown in the disk utility and its name changed, i dont know how that happened, i tried verif

    Help needed. I have a 3TB external hard drive partitioned into 1TB's. I used one partition as backup for the main computer hard drive. But now it is greyed out as shown in the disk utility and its name changed, i dont know how that happened, i tried verifying and repairing it but had no luck. I also tried mounting and unmounting it but still no solution. Anyone to help please?

    Looks bad. I would strongly advise backing up the stuff on the other two partitions as soon as possible in case the rest of the drive goes wrong.
    Beyond that, Disk Utility has limited abilities to repair disks, DiskWarrior uses a different approach and might, emphasis might be more successful. It has certainly done the job for me in the past when Disk Utility could not.
    See http://www.alsoft.com/diskwarrior/

  • I have 5 html pages that share a common header, footer, and sidebar. how do i use my nav bar to change the content of the body without duplicating a lot of code?

    i have 5 html pages that share a common header, footer, and sidebar. how do i use my nav bar to change the content of the body without duplicating a lot of code? thank you!

    i inherited the website. It’s for a non-profit and is not very
    sophisticated, and neither am I in webdesign. It currently has multiple
    pages that are identical except for that body section, so whenever i change
    the navigation (in the sidebar) I have to update every html page.  I want
    to have one basic page, and just call in the different body content based
    on the link the user selects from the nav bar. How can i do that using a
    script? i am using Dreamweaver.
    ~ in love and light ~
    Jeannie
    On Sat, Feb 7, 2015 at 4:07 AM, Ben Pleysier <[email protected]>

  • When I try to turn on my homesharing on apple TV it says that either my apple id doesn't exist or the password is wrong. However, I've been using the id for almost half a year and I even changed my password and it still wouldn't work. How do I fix this?

    When I try to turn on my homesharing on apple TV it says that either my apple id doesn't exist or the password is wrong. However, I've been using the id for almost half a year and I even changed my password and it still wouldn't work. What can I do to fix this?

    Not sure if this Term is Relevant towards an iPhone but, my iPhone won't Post unless if it's plugged into a Charger.

  • When I use Firefox and Hotmail at startup, Firefox freezes for about 1 minute, and then I can continue. First I though it was my computer but 2 other girls in my class have the same problem with Hotmail and Firefox. What can I do to change this?

    When I start Firefox, about 15 seconds after I start it, my Firefox freezes for about 1 minute. I found out that it is my Hotmail that makes Firefox freeze.
    First I thought it was my computer, but I have 2 other girls in my class that use Hotmail and Firefox and their computer also freezes for 1 full minute.
    This is very annoying, what can I do to change this?
    xxx ellen
    p.s. I am from the Netherlands, maybe that has something to do with it?

    Try deleting cookies and cache:
    1. Tools| Clear recent history
    2. Time range to clear: Everything
    3. If it isn't already selected, select '''Cookies''' and '''Cache'''
    4. '''Clear now'''
    '''Check cookie exceptions'''
    1. Tools | Options | Privacy Panel
    2. Set '''Firefox will: Use custom settings for history.''' '''Insure Accept cookies for sites and accept third-party cookies''' is selected
    3. Click '''Exceptions'''. If the misbehaving site is in that list, select it and click '''Remove site'''
    '''Safe Mode'''
    Add-ons can cause problems with not being able to log into certain websites. To see if this is the case with your issue, run [[Safe mode]]. When you get to the safe mode window, select Continue in Safe Mode. If this resolves your problem, see [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    Also see [[Updating Firefox]] and [[Cannot log in to websites]]

  • My computer is saying it can't find the file 'iTunes64.msi' when I try to update or redownload iTunes how do I fix this? I've tried just about everything I can think of. I am using a dell laptop running windows 7 and have tried changing the file loca

    My computer is saying it can't find the file 'iTunes64.msi' when I try to update or redownload iTunes how do I fix this? I've tried just about everything I can think of. I am using a dell laptop running windows 7 and have tried changing the file location to run the update in all of my iTunes files as well as when I've tried reinstalling it.

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there are also links to backup and recovery advice should it be needed.
    tt2

  • I changed companies and had icloud with my old company - now i want to just use my personal id and can't change any icloud info to match my personal ipad id - i can't delete the icloud without the old company id and password which is not available to me

    i changed companies and had icloud with my old company - now i want to just use my personal id and can't change any icloud info to match my personal ipad id - i can't delete the icloud without the old company id and password which is not available to me - it probably doesn't even exist anymore!
    Because I can't delete the icloud account, I keep getting view terms to accept and it wants to go to the old company account.  I can't do anything to get rid of this - when I try to delete the icloud it wants me to delete find my ipad and asks for the old co. id and password - it's a vicious circle and i just want to get rid of it and start fresh with my regular personal email id and password!!!  Help!

    You will need that old Apple ID and password, which does indeed still exist. Apple doesn't delete Apple IDs, though if this ID was in the control of your company they may have changed the password. If so, you will need your former company to log into the iCloud account using that ID and password and erase the iPad or remove it from iCloud:
    http://support.apple.com/kb/TS4515?viewlocale=en_US
    Until that's done you cannot change those settings, and if you try to restore the iPad will have it locked with Activation Lock and thereafter be unusable.
    Regars.

  • I have moved from the US to Norway, and want to change my apple ID to the Norwegian appstore. However, I am not allowed ot change from the US store before I use up my balance, which is 0.17 dollar. The problem is that nothing costs 0.17 dollar.Please help

    I have moved from the US to Norway, and want to change my apple ID to the Norwegian appstore. However, I am not allowed ot change from the US store before I use up my balance, which is 0.17 dollar. The problem is that nothing costs 0.17 dollar and I do no longer have an american visa card, only Norwegian. Is there any way I can erase the credit on my account so I can change the appstore country? Or osmething I can use this credit on? Thank you very much

    Try contacting the store support staff at: http://www.apple.com/emea/support/itunes/contact.html they are usually pretty good at sorting out these issues.

  • If I use the same iCloud account for my ipad and iPhone, will changes I make on one change on the other as well?  I'm not sure of the advantage of using teh same iCloud for both devices.

    If I use the same iCloud account for my ipad and iPhone, will changes I make on one change on the other as well?  I'm not sure of the advantage of using teh same iCloud for both devices.

    No, it only mirrors changes to synced data.  This includes mail, contacts, calendars, reminders, safari bookmarks, notes, iWork documents and data, and photo stream photos (assuming you choose to sync all this data).  Changes to iTunes data such as music, apps, podcasts, etc., are not synced using iCloud.  In your example, if you delete an app from one device it will remain on the other until deleted there too.

Maybe you are looking for

  • Repeated lost connections when using WRT54g

    Hello everyone. I have a Lynksys WRT54g v5 and a cable modem, my ISP is Virgin Mobile. Every half an hour or so my internet connection is lost and can only be regained by reseting my modem by turning it on and off. The lost connections appear to occu

  • Help with floating table

    I'm helping my dad with a website and he wants the table sidebar i have to float down the page when the viewer scrolls. I know next to nothing about coding and could use some help updating it to be a floating table.

  • IPA unicode text in flash through shared fonts

    hi Can any one tell how to access IPA unicode text from xml file I use shared object concept in flash cs3 but still i can acess text of "02A4" this hexadecimal values you can read view IPA text from http://www.phon.ucl.ac.uk/home/wells/ipa-unicode.ht

  • How to report on Alternate Units of measure

    Hi , I am trying to implement the unit conversion ..i have few basic questions.. 1)Do we need to have the 0MAT_UNIT in the cube/ODS 2)for 0material do i specifically need the base unit of measure as unit for the attribute conversion factor.. How do i

  • Satellite A200 won't boot from recovery disk

    I need to reinstall the notebook but every time I boot from CD it won't. I tried every boot disk ( xp pro, xp home, Toshiba recovery disk ) at house but none of it works. The recovery disk boots (windows is loading) but after loading my laptop restar