Is this DAO method too complex?

Below is a method that I want to implement for my Machines DAO class, which queries the database for machine tuples matching the specified criteria (xxxIs parameters) and returns only the projected columns (getXXX parameters). This method is designed specifically to support a search screen in my interface, which allows the user to specify the set of columns to view/retrieve (to limit network overhead) and the search criteria.
Collection findMachines(boolean getMachineID,
                             boolean getMachineName,
                             boolean getStatus,
                             boolean getExpirationDate,
                             boolean getPurchaseDate,
                             boolean getPurchasePrice,
                             boolean getOwnerName,
                             boolean getLastModifiedByID,
                             boolean getLastModifiedByName,
                             boolean getLastModifiedAt,
                             boolean getSectionID,
                             boolean getSectionName,
                             boolean getPlantID,
                             boolean getPlantName,
                             String machineTypeIs,
                             String machineMakerIs,
                             String machineModelIs,
                             String machineNumberIs,
                             String statusIs,
                             String sectionIDIs,
                             String plantIDIs
                             ) My question is:
1. Most of the DAO examples I've seen contain simple find methods with one or two paramters. But in my code, I often find the need to create a complicated find method like the one above to support flexibility in the user interface and provide better performance (doing a single SQL query instead of mulitiple ones). Nonetheless, these complicated find methods seem very inelegant, so is there a better way?
2. The Value Object returned by such method would contain several null fields for columns that are not projected. Furthermore, several attributes in this Value Object are there only to support display columns in the user interface, and are not needed by other parts of the system. This seems quite inelegant to me.

eyilin, you may either consider yourself lucky or unfortunate, as I'm in a loquacious mode this evening. I'll going to take your questions in reverse order.
2) Your VO should reflect the underlying data, not necessarily the other way 'round. Yes, database calls are "expensive," but you can throw away whatever you've gained using the reduced-set queries by moving through convoluted conditionals in an attempt to not "waste" data (non-used fields). You say the user display portion will not need certain fields for certain displays. So what - you're either going to ignore a null or a occupied field. There's no difference there. What happens if you need to change the display to add a field? Now, you have to change the call to the persistence layer, as well. If you already had the data, you'd just change the display code.
1) Do not try to make a single persistence layer method "one size fits all." As above, you'll end up blowing more time (both in writing the durn thing, as well as code-execution) than you think you'd save. If you need specific "finders" for specific parameters, each one is a separate method: findByMachineId, findByMachineType, etc. Keep these methods together in one class, for sure. That way they can share certain repeated code blocks, like a single private MachineVO resultSetToVO(ResultSet rs) - which is where #2 comes into play. If you need to narrow results for display purposes, you don't necessarily need to go back to the database - you already have the data; just select a subset to display (this can be done in the for loop constructing the display). Need to drill in to a single MachineVO? You've already got it - so just display it.
Finally, to be quite frank, your single method call will be guaranteed to be an absolute nightmare to maintain. Part of the big deal with maintenance is that it helps if it makes semantic sense. Two examples:
Example 1:
Collection machines = findMachines(true,true,true,false,true,false,false,false,
      false,false,false,false,false,false,
      null,null,"THX1138",null,null,null,null);
Example 2:
MachineVO[] machines = findByModel("THX1138");You'll find it quite unlikely that you'll need methods like findByModelPlantAndOwner.

Similar Messages

  • "Can not perform this operation because the layout is too complex"

    "Can not perform this operation because the layout is too complex"
    to create a 3D extrusion
    Hello
    Is it possible to work around and solve this problem?
    Without going through the box: cutting 4 part
    please
    xavier.

    Merci Violon popur tes conseilles, cool !
    After clipping of an object on a photo
    I want to make a 3D extrusion.
    With a picture of this size that does not work :
    1979/2765 300PP 31,3Mo
    I have this error message appears: “ Can not perform this operation because the layout is too complex ”
    For successful operation
    I must necessarily reduce the size of the photo to
    597/834 300PP 2,85Mo !!!
    How not to lose the pixel ?
    I need it additional plugins ?
    Version Adobe Photoshop : 14.2 (14.2 20131211.r.515 2013/12/11:23:00:00) x64
    Système d'exploitation : Mac OS 10.9.1
    Architecture système : UC Intel Famille :6, modèle :44, niveau :2 avec MMX, SSE Entier, SSE FP, SSE2, SSE3, SSE4.1, SSE4.2, HyperThreading
    Nombre de processeurs physiques : 12
    Nombre de processeurs logiques : 24
    Vitesse du processeur : 2930 MHz
    Mémoire intégrée : 32768 Mo
    Mémoire libre : 27285 Mo
    Mémoire disponible pour Photoshop : 31299 Mo
    Mémoire utilisée par Photoshop : 90 %
    Taille de la mosaïque d'images : 1024K
    Niveaux de mémoire cache de l'image : 4
    2 X 2,93 GHz 6-Core Intel Xeon
    NVIDIA Quadro 4000 2048 Mo
    4 X 8 (32 Go) DDR3 @ 1066Mhz
    2 X OWC Mercury Extreme Pro 6G SSD Media (System acquisition / Projects)
      2 x 2 To de DD (5400tr/min)

  • What happened to the 24/7 live chat for mobile me? I need help right now. Too complex for this. Crime involved., What happened to the 24/7 live chat for mobile me? I need help right now. Too complex for this. Crime involved.

    What happened to the 24/7 live chat for mobile me? I need help right now. Too complex for this. Crime involved., What happened to the 24/7 live chat for mobile me? I need help right now. Too complex for this. Crime involved.

    Hi Tmswrite,
    Here is what you want to do to protect yourself and your device:
    Find My iPhone Basics  - Apple Support
    iCloud: Find My iPhone overview
    Here's some information on how the Activation Lock protects you:
    Find My iPhone Activation Lock in iOS 7
    Sorry for your troubles. Hope it turns out OK for you!
    GB

  • Could not complete the new 3D extrusion from selected layer command because the path is too complex.

    I was trying to do a photo of mine like in this video but its not working help needed. thanks.
    http://www.youtube.com/watch?v=egyLY78H7nE
    When I tried the 3D I got an error message that said (could not complete the new 3D extrusion from selected layer command because the path is too complex.) what does this mean and how can i fix it?

    There was a bug at one time where really simple paths (like a triangle, for example) could cause that error.
    Is your path really simple (I don't plan to go watch the video)?  If so, have you installed the latest update for Photoshop?  That bug may have been fixed already.
    If it's not that, it's possible that if your path is really complex and simply exceeding Photoshop's capability.
    -Noel

  • Call a method with complex data type from a DLL file

    Hi,
    I have a win32 API with a dll file, and I am trying to call some methods from it in the labview. To do this, I used the import library wizard, and everything is working as expected. The only problem which I have is with a method with complex data type as return type (a vector). According to this link, import library wizard can not import methods with complex data type.
    The name of this method is this:   const std::vector< BlackfinInterfaces::Count > Counts ()
    where Count is a structure defined as below:
    struct Count
       Count() : countTime(0) {}
       std::vector<unsigned long> countLines;
       time_t countTime;
    It seems that I should manually use the Call Library Function Node. How can I configure parameters for the above method?

    You cannot configure Call Library Function Node to call this function.  LabVIEW has no way to pass a C++ class such as vector to a DLL.

  • Subtitles too complex error - in PAL subtitles only

    I have a project that is going to be authored in both PAL and NTSC. It has subtitles in six languages.
    On the NTSC one, everything burns fine.
    On the PAL one, I get an error when burning saying "subtitle or menu subpicture too complex."
    We have the same subtitle scripts being used in both, and the menus are the same beside the difference in dimensions (I think there is probably some slight movement of button position). The dimensions for the subtitle cells entered in the PAL version are actually slightly smaller in height, but the same width as the NTSC.
    NTSC, I have the dimensions of the subtitle boxes set to:
    92 628
    325 445
    PAL:
    112 608
    450 525
    I am in the process of narrowing down which subtitle tracks are causing the errors, but does anyone have any insight into why this would happen only in the PAL version when both are using the same subtitle scripts?

    sorry - two things I forgot to mention: CS4 and Mac OS 10.5.8

  • Page too complex error message

    Hi all; new to this forum. I have a HP2840 laser (color and black and white) all in one printer which is appx. 1 year old. I keep getting error message "page too complex" and cannot print page. Also, the printer always took a long time to print anything out, but now it won't print. Can my printer memory be full?  Any thoughts would be appreciated. thanks. 

    This is a quote from another post. This is not from my own in anyway shape or form. I am sorry I dont have the person that found this fix and I would like to thankthe person that did find this one.
    In order to fix this you need to turn off High Speed USB in the Secondary Service menu.
    To access the Secondary Service Menu press the Menu button and the number 2. Use the < arrow to navigate to the High Speed USB selection.
    Press Enter and then use the arrow key to go to Off and press Enter again. Press the Cancel button twice to exit the Secondary Service Menu

  • Clipping mask, object too complex, can't use bitmap either

    Hi all,
    I'm in Illustrator CS4 trying to make a page that has content that I want to embed within a rounded rectangle.  Sounds easy enough.
    I've been successful sticking some content into a rounded rectangle, until now.  Now I have a page that apparently is "too complex".  It has lots of transparencies and gradients and such.  Once I try to do the clipping mask thing I am told it's very complex and may not print or work right.  I go ahead anyway and it just looks blank/invisible.
    Then I thought artboards might be a way to do this, but I couldn't see how you could make an artboard that is a shape other than a rectangle (I'd like a rounded rectangle).
    So then I thought if export the image to a bitmap and then repaste it in, maybe I could embed the bitmap into the rounded rectangle.  Pain in the butt, but I'm looking for any solution.  But that doesn't even work because it says the top selected object must be "a path, a compound shape, a text object, or a group of those".  So a bitmap can't be used
    Has anyone had more luck with this?  In CorelDraw I've always just placed objects, no matter how complex, into a "container" without any issues.  Certainly there's a way to do the same here.  This drawing isn't *that* complex.
    Thanks in advance for your advice!

    Check your flattener settings in the prefs, specific flattening options of your object groups and also the raster effects resolution for your document. Reduccing their dpi should make working possible.
    Mylenium

  • CS6 3D error (bug?) "Could not complete your request because the path is too complex."

    I'm running into a bit of a problem with having a shape extruded in 3D.
    If I draw a rectangle shape set to path over an image and then choose "source - work path" and "3D extrusion" I will get a 3D rectangle with the image on the front side.
    If I draw a 3 sided polygon (triangle) set to path over an image and then choose "source - work path" and "3D extrusion" I will get a error telling me that the path is too complex.
    I'm doing the exact same thing.
    Now, if I have 4 sides plus, on the polygon it will extrude just fine.
    Something seems to be happening with 3 sided polygons.
    This holds true with the pen tool as well. Three points will give you the error, 4 and above seem not to.
    Any ideas and to why this is happening?
    Thanks!
    Lux
    CS6 - latest build
    Mac 12 core
    24gigs Ram
    Cloud subscriber

    Work around. (CS6)
    (1) Draw your trangle shape.
    (2) Convert one of the corners to a smooth corner (just barely). If you doesn't work, bend flex it a little more, and try again.
    (3) 3D/New 3D extrusion from selected layer.
    (4) Switch camera to top view.
    (5) With 3D layer selected, in the coordinates menu of Properties panel, set X angle to 90.
    (6) Snap object to ground plane.
    (7) Set depth to 0.
    (8) In the Cap menu of the Properties panel, adjust cap width to 100%.

  • "Could not complete your request because the path is too complex"

    I'm trying to render 24 characters of text with line breaks in 3D, because, as we know, 3D can be very spiffy... but I get:
    "Could not complete your request because the path is too complex"
    Interesting, I'm on a rocketship workstation with a fairly stealthy config. All is updated to the latest ver., 13.1.2.. Not the greatest card in the world (Quadro 2000), but it seems more than ample for this task..
    It works fine with 9 characters on one line... Ok, possibly (or rather likely) I have too much text (24 characters? Line breaks? Trebuchet?), but frankly, I'd be surpised... What are the limitations here? Tips?
    Thank you!

    In this case, I have photoshop doing all the number crunching through GPU:
    Also, my performace settings (this is 32-bit PS, so it only sees 4GB):
    We'll see what any Adobe folks say, thank you very much for your time and insights!

  • SSAS DRILLTHROUGH - Specified query is too complex error.

    Hi Guys,
    I'm working on an SSAS 2012 OLAP cube with around 100 dimensions and a single measures group. When I try to run a simple DRILLTHROUGH query such as:
    DRILLTHROUGH
    MAXROWS 1000 SELECT
    FROM [Cube] WHERE ([Measures].[Fact_Count])
    I get an error as below.
    The specified query is too complex to be evaluated as a single statement.
    Does anyone have any experience of this error and how to work around it? If I remove the majority of the dimensions from the cube I can run this query successfully. Looking at the limits set for analysis services I should be well within these.
    Thanks in advance 
    Sean

    Hi Scaneyw,
    Based on my research, this is a SQL Server Analysis Services (SSAS) design limitation. In SSAS, Drillthrough” generates internal CrossJoin query that contains all attribute hierarchies in measure group. So the error appear when MDX parser receives statement
    with> 1000 nodes.
    Here are some tips for you to avoid this error.
    Reduce number of dimension attribute hierarchies in measure group below 1000.
    Delete unneeded attributes and disable Hierarchy for attributes that are only used as properties.
    Consider creating smaller Measures Groups with less dimensions + attribute hierarchies.
    If you have any concerns about this feature, you can submit a feedback at
    http://connect.microsoft.com/SQLServer/Feedback and hope the complete “drillthrough” feature is will be improved in future SQL Server Versions.
    Regards,
    Charlie Liao
    If you have any feedback on our support, please click
    here.
    Charlie Liao
    TechNet Community Support

  • BT Mapper error : The style sheet is too complex

    Hi Guys,
    I am trying to test the map in visual studio and I immediately prompted with the error “XSLT exception: The style sheet is too complex”. I have searched for this on the web and came to know that this might be caused by number of lines in XSLT and my BT mapper
    is very big. And I can confirm that this is not due to any mapping errors or syntax errors because I checked the same mapping using few lines of xslt and it worked.
    Does anyone has seen this error in BizTalk mapper? I am testing the map using “Test map” in visual studio.
    I am using BizTalk server 2013 R2 Dev with visual studio 2013.
    Thanks
    JB

    Hi JB,
    There is a known issue with framework 4.5 as mentioned in the given article:
    http://support.microsoft.com/kb/2828841/en-us
    Trying applying this hotfix and make the config changes as mentioned in the below article.
    BizTalk
    2013 Orchestration fails with Error "The Stylesheet is too Complex"
    Rachit
    Please mark as answer or vote as helpful if my reply does

  • Subtitles are too complex.

    I' am making a DVD using all image files from CaptionMax. See post from yesterday:
    stevenl, "Image Subtitles." #1, 10 Apr 2006 4:34 pm
    Anyway in just a test of the whole subtitle thing I only imported 1 subtitle track and tried to burn a folder and/or image file and got a message telling me that my one track is too complex. I'm going to need seven more, so if you think it's complex now??? All I did is set my first play to Timeline 1 with the one track set to display. Now, I have another timeline in the project that I set as the end action of the first with its track set to display. Can there be an issue in that the two timelines are different aspects 1 is 16x9 and 2 is 4x3?
    I don't think that my problem should be anything related to this thread:
    ivansull, "EncoreDVD 2.0 Subtitles" #10, 21 Mar 2006 10:46 pm
    since my subtitles are all index .tif files that are already as small as they're going to get. I've also used these type of files in our Sonic DVD Fusion system many times and never had this kind of issue.
    I've read about other Encore issues with subtitles, but most of them seem related to text subtitles, what issues (if any) are there with image files?
    Thanks,
    Steven

    Steven,
    The "too complex" error is probably the one mentioned in post #5 of the "EncoreDVD 2.0 Subtitles" thread. This is not an Encore issue, but a limitation set by the DVD-Video specification. It doesn't matter whether the subtitles are imported via a text script or as bitmap images; if any (horizontal) line exceeds 1440 bits it exceeds the spec maximum.

  • Page too complex to print

    Since updating Safari to version 5.1.3 and later (now 5.1.5) my HP 2605dn printer balks on printing some Web page with the error message, "Document too complex to print" and I have to recycle the power and empty the print queue. This wasn't a problem before as it printed any page Safari sent it. I'm wondering if others are having this same problem with Safari. There are some Web pages I have to print independent of others and some which just won't print anymore.

    Hi...
    Just a thought, but you mIght have better luck printing from another browser ...
    Mozilla Firefox Web Browser — Free Download
    Or  Google Chrome
    Or  Opera Web Browser

  • How many exceptions to be thrown by a DAO method

    Suppose I have a DAO method:
    public Department getDepartmentById( int departmentId) throws DepartmentNotFoundExceptionNow inside this method, if no Department is found having id equal to departmentId then I throw DepartmentNotFoundException.
    But there are couple of things which can go wrong in this method which have nothing to do with Department: For example could not get/open a Connection; ResultSet problem; could not close Connection etc. I am catching all these kinds of exceptions as well. My question is
    1) should I throw DepartmentNotFoundException in such cases as well although they have nothing to do with Department
    2) throw another exception say InfrastructureException and change the method signature to:
    public Department getDepartmentById( int departmentId) throws DepartmentNotFoundException, InfrastructureExceptionWhich is better solution and why? Is it a standard to only have one exception thrown by each DAO method?
    Thanks

    Now inside this method, if no Department is found
    having id equal to departmentId then I throw
    DepartmentNotFoundException.
    But there are couple of things which can go wrong in
    this method which have nothing to do with Department:
    For example could not get/open a Connection;
    ResultSet problem; could not close Connection etc. I
    am catching all these kinds of exceptions as well. I would catch all these and turn them into a generic DepartmentException
    question is
    1) should I throw DepartmentNotFoundException in such
    cases as well although they have nothing to do with
    Department
    2) throw another exception say
    InfrastructureException and change the method
    signature to:
    public Department getDepartmentById( int
    departmentId) throws DepartmentNotFoundException,
    InfrastructureException
    An object can throw any number of exceptions. It think it is more an issue of personal style.
    Here is my style:
    public class DepartmentException extends Exception { ; }
      public class DepartmentNotFoundException extends DepartmentException { ; }
      public class DepartmentNotWorkingException extends DepartmentException { ; }
      public class DepartmentIsMarketingException extends DepartmentException { ; } 
      public Object getDepartmentById( int departmentId )
        throws DepartmentException
          if (departmentId < 0) {
            throw new DepartmentNotWorkingException() ;
          if (departmentId == 0) {
            throw new DepartmentIsMarketingException() ;
          if (departmentId > 99) {
            throw new DepartmentNotFoundException() ;
          return new Object() ;
        try {
          try {
            instance.getDepartmentById( 1 ) ;
          } catch( DepartmentNotWorkingException departmentException ) {
            departmentException.getLocalizedMessage() ;
          } catch( DepartmentIsMarketingException departmentException ) {
            departmentException.getLocalizedMessage() ;
          } catch( DepartmentNotFoundException departmentException ) {
            departmentException.getLocalizedMessage() ;
        } catch(DepartmentException departmentException) {
          departmentException.printStackTrace( System.err ) ;
    Which is better solution and why? Is it a standard to
    only have one exception thrown by each DAO method?I cant justify it beyond saying it works for me.

Maybe you are looking for

  • HCM Processes and Forms - Confirmation Text Formatting

    Hi All, I am attempting to use the Confirmation Txt in the Scenario Steps of a form. When the editor comes up, there are not options for formatting available. According to the help system, the text editor provides you with XML formatting options as b

  • How can i fetch only the updated contacts from SQLServer to local SQLite database?

    Hi, I need to update my local AIR Contact application (HTML/AJAX) with the new contacts from the SQL Server (interacting with J2EE). How can i do it? Do, i have to create a background thread which Pulls (requests) data periodically, and the server re

  • Virtual Network Adapter (vEthernet) unauthenticated

    Hi,  I have a problem, with configuring a Virtual Network Adapter on SC VMM.  I created a logical switch with two physical network adapter (team) and add a virtual network adapter to the logical switch. After that a virtual network adapter will be cr

  • Is it possible to pass a auto credit entry in miro

    Is it possible to pass a auto credit entry in a seperate gl while doing  miro equal to a debit entry done in another gl in same MIro only expense 100         (from migo)              to suspense gl 100   (auto entry)

  • Flash player keeps crashing on Mac. Help?

    Every time I try to watch a video, flash player crashes. I tried uninstalling and reinstalling it, and when that didn't work I did a full clean install. I also reset my web browser to see if that would help. I use Firefox, but I tried it on Safari an