Should every SQL query have its own event and command?

Hello,
I am developing an application using Cairngorm. My app uses SQL databases.
I'm creating a separate event and command for each SQL query my application requires. I end up with many events  and commands - twenty different event/command pairs and I'm not even done yet.
I was wondering if this is the right way to go, or if somehow similar SQL queries should be grouped together in the same event/command, and if so, how would I implement that elegantly?
I've never used Cairngorm before so I want to make sure I do it correctly.
Thank you for your time and any assistance you can offer.

From my point of view, writing any SQL query or making queries directly from the presentation layer (eg. flex) to the db server it's almost always incorrect, awfull and maybe even insecure. The client layer should be more independent from the implementation layer as for instance the db server you are using. Instead you should call services on the server side and then they should have a DAO layer o whatever where the queries are done. You could then invoke one of this services and pass parameters that indicates what you want to do. (except you are using remoting where you will be invoking methods directly)
Consider the case where you have a Java implemented service layer, you could be using hibernate to access the database and not writing a single line of SQL (maybe some HQL) and then you could do all the queries you need and return the beans retrieved from the database to the client layer using AMF3 and it's serialization/deserialization mechanisms. In a future you could modify your app to use JPA and then this layer use hibernate, then you client layer will remain the same the only changes will be done under the DAO layer.
So again, in my opinion, db server should never be accesed directly from the presentation layer (Flex, Air or whatever) but from the backend services and this sould be completly abstract to the client layer. I have seen some people trying to do SQL queries from Flash but that it's giving a task to the Flash player it has never been intended to do. A miss use of the thin client the Flash Player is and an bad architecture.
It would be great to hear others opinions.

Similar Messages

  • When should a subclass have its own fields and when should it use its super

    When should a subclass have its own fields and when should it use its superclass' fields?
    Hi, thank you for reading this post!
    Let me use a specific example to ask my question.
    public class BankAccount {
         private double accountBalance;
         public double getBalance() {
              return this.accountBalance;
    public class SavingsAccount extends BankAccount {
         private double accountBalance;
         public double getBalance() {
              return this.accountBalance;
    }In the bank account example, both BankAccount and SavingsAccount will have a method getBalance(). Therefore, they
    both require a account balance field. My question is since getBalance() for both classes will perform the exact same
    operation, when should I omit declaring the getBalance() method and the accountBalance field in the subclass, and
    when should I include them?
    My own thought is when we never have to instantiate a superclass object (e.g. an abstract class), then we place
    common fields in the abstract superclass and have subclasses access these fields via protected getter/setters to
    access the superclass' fields. This is the principle of reuse.
    But when you do need to instantiate a superclass and the superclass does need to maintain its own fields, then
    I would need to duplicate the accountBalance field and getBalance() method in the subclass.
    Is my thinking correct or incorrect?
    Thank you in advance for your help!
    Eric
    Edited by: er**** on 22-Aug-2011 20:19

    er**** wrote:
    If SavingsAccount inherit BankAccount.getBalance()...getBalance() would return BankAccount's accountBalance. This is NOT the correct result we want.Actually, I think it's precisely what you want.
    We want getBalance() to return BankAccount's accountBalance when we use a BankAccount object, and SavingsAccount's accountBalance when we use a SavingsAccount object.I seriously doubt that. I think you're confusing a BankAccount with a Customer, who can have more than one account.
    In every system I've ever seen, a SavingsAccount IS-A BankAccount - that is to say, it's a genuine subtype. Now, it may well contain other fields ('interest'?) that a normal account wouldn't, but 'balance' ain't one of them.
    Winston

  • This is an odd one, does Logic have its own clock?

    Hey all,
    This is one for the books over here. Does Logic have its own clock? Not as in clocking, 44.1 48 etc. Not in that respect, but rather does Logic have its own "date and time" clock separate from OS X?
    Here's what's happening...
    We have two rooms here. Identical. Writing done in "A" gets sent over to "B", cleaned up, sent back over to "A" etc etc. So in the "A" room, a cue comes from "B" with a last opened time of last night at 10:00 pm. A last modified time of 10:15 pm last night. That's the data if you get info on it from a finder window. Now with Logic open if you "open" a cue from Logic, navigate to where this cue is at, it says that the cue was last opened TONIGHT at 9:40pm (which is in the FUTURE) and last modified TONIGHT at 9:55pm (also in the FUTURE). We've caught it now, and things seem to be okay if you open a cue from the finder window and not from Logic->File->Open. A cue was opened from Logic yesterday, two hours of work done, saved often, and when it was closed and then opened again after lunch, none of the work was present. And the date and time modified was again in the future. So SO weird. Cleared prefs, repaired permissions. Still happening. Anyone else experiencing this? Any tips? Advice? Does Logic have its own clock? We're baffled.
    Any help is greatly appreciated as always!
    Best wishes,
    the Earle-Tones Music crew

    Brent, thanks for seconding in here. Sometimes this kind of you'd-never-expect-it-to-happen-weirdness can be easily written off as some kind of itinerant digital voodoo without this kind of corroboration.
    So while we're on the subject of the finder lying... Folders are no picnic either.
    If you create a folder and never open it but throw a bunch of stuff into it within the same minute that it's created, its creation date and modification date will be the same. But the simple act of opening that folder for the first time can cause its mod date to change. Or, if you go into that folder and re-organize some items, or rename some items, the folder's modification date will also change.
    This means that if you have a bunch of folders contained within another folder (the "containing folder"), and you re-organize/re-name items within those folders, you can't count on the modification date of any one of the contained folders to indicate the order in which they were originally created. Because of this behavior you'll want to view by date created. But I still can't get my head around the idea that manipulation of data within a folder causes the attributes of the containing folder to change.
    This may have some bearing on your current situation... or then again, maybe not LOL!   : - )
    -=iS=-

  • How to run recordset SQL query in FORM DATA event

    How can I run recordset SQL query in FORM DATA event upon clicking on Add button in the document?

    Hi Slamet,
    When you receive a form data event you have a class containing inside it a ObjectKeys xml info regarding the object added/modified,...
    With the objects keys you can then use the DI API method called GetByKeys to obtain the DI Object.
    There is some information about it in the SDK Help file, mainly in the "FormDataEvent" class definition:
    <i>The event provides the unique ID (BusinessObjectInfo.ObjectKey) of the modified business object. You can use the value of this property as an input parameter in the DI API DataBrowser.GetByKeys method to get a DI object.</i>
    Pay attention you don't have this information in the Before=True event of the Add as it is not yet in the database.
    Hope it helps
    Trinidad.

  • Does each new page that I attach to my home page have to have its own style sheet?

    Does each new page that I attach to my home page have to have its own style sheet or should it all just go on the home page one?

    Different answers depending on your project & workflow.
    I like to keep all my sitewide styles in an external css file.
    Page specific <styles> can be embedded into the document's <head> tags.
    And for line specific styles (mostly used for HTML emails), inline styles can be added to the markup.
         <p style="color:red">example of a paragraph with inline style</p>
    Now, let's say you're building different layouts for different devices.  In that case, you really must keep all related styles in their respective external CSS files.
    print.css
    mobile.css
    tablet.css
    desktop.css
    There's no one size fits all here.  Use whichever method works best for you & your project.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • HT5616 I have multiple phones and iPads and all are linked to one iCloud account and one iTunes Account.  I want to keep the same iTunes Account so I can share music, etc., however, I want each device to have its own iCloud account.  How do I do this?

    I have multiple phones and iPads and all are linked to one iCloud account and one iTunes Account.  I want to keep the same iTunes Account so I can share music, etc., however, I want each device to have its own iCloud account.  Any help on how I can I do this?

    You'll need to create an Apple ID for each device. Use the new Apple ID for FaceTime, iMessage and iCloud on the device. Use the original Apple ID for Settings>iTunes & App Store.

  • ITunes Automatically Change EQ Setting Based On Which Airport Express Streaming?  I have two Airport Expresses running at my house. Both are connected to different types of speakers. Neither speaker set has its own equalizer, and both require a different

    I have two Airport Expresses running at my house. Both are connected to different types of speakers. Neither speaker set has its own equalizer, and both require a different EQ setting to sound just right. Does anyone know of a way to have iTunes automatically change its EQ setting based on which Airport Express it is streaming to?

    I'm in the same boat. I have a 6 zone amplifier running with 6 airport expresses to different rooms inside and outside the house. Each has it's own acoustic characteristics. I'd really love to be able to set each airport to equalize based on my SPL frequency sweep I did for each room.
    Setting the eq in itunes won't do it as that is global plus I have many more sources for auiod other than itunes that use the AEs directly.

  • Can a book in Ibook have its own passcode before it can be opened?

    Can a book in iBooks have its own passcode before it can be opened? (I wrote a book in IBook Author and exported it to IBooks. Need passcode for privacy reasons).

    Oh, that's too bad...well, let me know if they ever come up with that idea. Thanks.

  • Can anyone explain the split and overlapping date ranges in PHOTO moments.  I would have expected each date to have its own slot.  What logic is used for deciding which photos to include and where to split them?

    iPad Air iOS 8.1 Stock Photo App.  14000 Photos. Overlapping date ranges in Moments.  What is the criteria used for deciding after import where photos are included in Moments.  I was expecting each day to have its own exclusive slot for example, not 26 - 27 January 2007 with 8 photos then 27 January 2007 1 photo.  Why is there not two seperate slots, one for the 26th and one for 27th??   This makes locating photos by day more arkward than it need be and seems to follow no logic.  This occurs over 150 times and is very confusing.  Is this an issue or expected behaviour?

    iPad Air iOS 8.1 Stock Photo App.  14000 Photos. Overlapping date ranges in Moments.  What is the criteria used for deciding after import where photos are included in Moments.  I was expecting each day to have its own exclusive slot for example, not 26 - 27 January 2007 with 8 photos then 27 January 2007 1 photo.  Why is there not two seperate slots, one for the 26th and one for 27th??   This makes locating photos by day more arkward than it need be and seems to follow no logic.  This occurs over 150 times and is very confusing.  Is this an issue or expected behaviour?

  • Printing on HP LaserJet P1102w from iPad2 via AirPrint: is printer supposed to have its own network?

    Or is printer meant to have its own network? When I want to print, I have to disconnect my iPad2 from my 'Belkin54g' home WiFi network & connect it to the 'HP-Print-4F-LasetJet 1102' network that is listed (under 'Choose a Network' on my iPad2's Settings/WiFi page).
    Once the printing has finished, I need to re-connect my iPad2 back to my Belkin WiFi network.
    iPad2 shows the printer has/is on its own separate distinct WiFi network & my WiFi/Internet Router/Access Point is on its own one; both show up as such ("'HP-Print-4F-LasetJet 1102" for the printer & "Belkin54g" for the WiFi).
    Please can anyone advise me if this is correct, or if I have set it up incorrectly?
    And if so, where/how I would need to change this? I was going to have a look in the web-page based Config pages for the printer & my router.
    Any help/advice would be gratefully received. It seems to take ages for my iPad2 to reconnect to the WiFi router once I finish printing (upto 20mins, which makes printing very time consuming, although this is probably a separate issue in itself!).
    Thanks, Si.

    Hi simonbond,
    I understand you have a new router and are unable to setup the printer on the new network.
    Thank you for your reply.
    I will be happy to help you with this.
    I would reset the printer first to clear out any previous network settings.
    Turn the printer off, hold down the wireless button and cancel (x button) while turning the printer back on and don't release the two buttons until the printer stops making noise.
    Print out a configuration report and make sure the SSID and IP address are cleared. (hold down the x button and when the printer makes a noise let go)
    After the reset, disconnect the routers power cable, wait 10 seconds, then reconnect the power cable. Wait till it's ready.
    Since the software is already installed then I would setup the wireless again by connecting the printer by USB to the computer.
    Then go to start, all programs, HP, Laserjet, wireless configuration wizard, follow the steps to setup the wireless. When finished remove the USB cable.
    Then try and print.
    Hope this helps.
    Thank you for posting on the HP Forums. Have a great day!
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • Need to paste on/off button in its own event structure?

    I am studying the CLD exam car wash vi attached.
    First question, I noticed the Start button is pasted inside its own event structure. Is this absolutely necessary, can I just paste somewhere else? 
    I guess it was paste there because the Start button has no wiring so it looks neater to paste in its own event structure, am I right?
    Second question, I noticed the Stop button is already wired to the red while loop stop, so pressing it would stop the vi already. But there is also the Stop value change event, this looks redundant, no? Or is it something really necessary??
    Solved!
    Go to Solution.
    Attachments:
    Car Wash LV86.zip ‏73 KB

    Both are necessary.
    1. The boolean's terminal while be read when the event is triggered. This read triggers the latch operation (so the button snaps back).
    2. The event structure would wait for an event and nothing would happen until another event is triggered. Only after the event structure is 'run', the stop value is read.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Does my hp envy 7640 have its own email address?

    When i was shopping for a printer a HP rep was there and said that the HP envy had its own email address. Is this true and if so how do you set it up?

    ELLEMAE
    Welcome to the HP Community Forum.
    Yes, this printer can have its own email address and you can send print jobs to your printer to it from the Internet.  It is a very cool feature. 
    HP ENVY 7640 e-All-in-One Printer
    NOTE:  You may have to use the above cached link to access the Printer's Support pages today.  The direct search link from Driver and support might be glitchy.    This is primarily relevant when / if you need to install the Full Feature Software for the Printer to find the Driver's page.
    HP ENVY 7640 e-All-in-One series - User Guide
    See the following for "how-to" and other information:
    Add Device to Printer
    Click the Kudos Thumbs-Up to say Thank You!
    And...Click Accept as Solution when my Answer provides a Fix or Workaround!
    I am pleased to provide assistance on behalf of HP. I do not work for HP. 
    Kind Regards,
    Dragon-Fur

  • 2.3 year old iMac (27inch) Hard Drive failing. Does the drive have its own warranty?

    My imac that is 2.3 years old is now having the S.M.A.R.T system saying the drive is "failing".  Does the drive have its own warranty? That's not very old for a failure and most HD manufactures have a 3 year minimum.  Now I wish I had bought the extended warranty period.  Shish. 

    TKRWH wrote:
    Does the drive have its own warranty? 
    No. 

  • Gateway restarting on its own again and again

    I have an application developed on iPlanet Application Server, integrated with the Portal using URLScraper. I am running the Application through the Gateway. The gateway is restarting on its own time and again and I have to log in again every time. At times the gateway restarts after 5 - 10 mins...At times, it goes on for 2 - 3 hours. Also, even when the gateway does not restart, I am shown the Portal Authentication menu page while working on the application. Apparently, something is happening to the session or to the gateway.
    In iwtSession, I found that a lot of sessions were being created and some were destroyed with 5 -10 minutes of being created, while only 1 person was working on the Portal. Could this be the problem?
    What all could be the reasons why a gateway would restart on its own? I have set the maximum idle time of the session to 30 mins. and the max session time to 800 minutes.

    The session are not set on the gateway but rather on the server. The gateway itself has a session with the server. The gateway restarts if it looses its session with the servers or if something else happens that forces the gateway to restart itself.
    Take a look at the web server error logs to see if the web server is restarting during the time the gateway is restarting. You can see this at /install_dir/netscape/server4/https-hostname/logs
    Also the additional log information that would be usefull here is the iwtGateway, take a look at that, at the time of restart. Make sure ips.debug=message when you look at the log files.
    What version of portal are u using ips sp3a ?

  • My wife and I share apple id but have our own phones, and now having trouble with imessage

    My wife and I share apple id but have our own phones, and now having trouble with imessage. Sharing calenders, apps, music, contacts, etc...all great. But when we imessage each other. Our phones get confused and either not deliver message, or send it to and from itself.

    Go to Settings > Facetime and you will see "You can be reached for video calls at:"
    This should list your phone number (iPhone) and your email address (probably the gmail one).
    And then an option for "Add another email..."
    Choose that and enter your @me.com account and it'll send a verification email.
    Same for iMessage: Settings > Messages > "Receive at" > Add Another Email
    So you can be called by facetime and use iMessage through multiple email accounts yes.

Maybe you are looking for