What is the best way of returning group-by sql results in Toplink?

I have many-to-many relationship between Employee and Project; so,
a Employee can have many Projects, and a Project can be owned by many Employees.
I have three tables in the database:
Employee(id int, name varchar(32)),
Project(id int, name varchar(32)), and
Employee_Project(employee_id int, project_id int), which is the join-table between Employee and Project.
Now, I want to find out for each employee, how many projects does the employee has.
The sql query that achieves what I want would look like this:
select e.id, count(*) as numProjects
from employee e, employee_project ep
where e.id = ep.employee_id
group by e.id
Just for information, currently I am using a named ReadAllQuery and I write my own sql in
the Workbench rather than using the ExpressionBuilder.
Now, my two questions are :
1. Since there is a "group by e.id" on the query, only e.id can appear in the select clause.
This prevent me from returning the full Employee pojo using ReadAllQuery.
I can change the query to a nested query like this
select e.eid, e.name, emp.cnt as numProjects
from employee e,
(select e_inner.id, count(*) as cnt
from employee e_inner, employee_project ep_inner
where e_inner.id = ep_inner.employee_id
group by e_inner.id) emp
where e.id = emp.id
but, I don't like the complication of having extra join because of the nested query. Is there a
better way of doing something like this?
2. The second question is what is the best way of returning the count(*) or the numProjects.
What I did right now is that I have a ReadAllQuery that returns a List<Employee>; then for
each returned Employee pojo, I call a method getNumProjects() to get the count(*) information.
I had an extra column "numProjects" in the Employee table and in the Employee descriptor, and
I set this attribute to be "ReadOnly" on the Workbench; (the value for this dummy "numProjects"
column in the database is always 0). So far this works ok. However, since the numProjects is
transient, I need to set the query to refreshIdentityMapResult() or otherwise the Employee object
in the cache could contain stale numProjects information. What I worry is that refreshIdentityMapResult()
will cause the query to always hit the database and beat the purpose of having a cache. Also, if
there are multiple concurrent queries to the database, I worry that there will be a race condition
of updating this transient "numProjects" attribute. What are the better way of returning this kind
of transient information such as count(*)? Can I have the query to return something like a tuple
containing the Employee pojo and an int for the count(*), rather than just a Employee pojo with the
transient int inside the pojo? Please advise.
I greatly appreciate any help.
Thanks,
Frans

No I don't want to modify the set of attributes after TopLink returns it to me. But I don't
quite understand why this matters?
I understand that I can use ReportQuery to return all the Employee's attributes plus the int count(*)
and then I can iterate through the list of ReportQueryResult to construct the Employee pojo myself.
I was hesitant of doing this because I think there will be a performance cost of not being able to
use lazy fetching. For example, in the case of large result sets and the client only needs a few of them,
if we use the above aproach, we need to iterate through all of them and wastefully create all the Employee
pojos. On the other hand, if we let Toplink directly return a list of Employee pojo, then we can tell
Toplink to use ScrollableCursor and to fetch only the first several rows. Please advise.
Thanks.

Similar Messages

  • (New to C# here) What is the best way to return false in a function if it cannot be executed successfully?

    In Javascript or PHP you can have a function that could return, for example, a string in case of success and false in case of failure.
    I've noticed (in the few days I've been learning C#) that you need to define a type of value that the function will return, so you need to return that type of value but in case of failure you can't return false.
    What is the best way to achieve this behavior and is there an example I can see?
    Thank you in advance,
    Juan

    Juan, be aware that returning null won't work with value types, such as an int, which can't be null. You'd have to use a nullable value type. A nullable int would be declared with a "?", such as:
    int? someOtherFunction(int param)
    if(something goes great)
    return param * 42;
    return null;
    And you have to use it like this:
    int? result = someOtherFunction(666);
    if (result != null) // you can also use result.HasValue
    // it worked, do something with the result
    // if you're doing math with the result, no problem
    int x = result * 2;
    // but if you're assigning it to another an int, you need to use this syntax
    int y = result.Value;
    Before nullable value types came along, for a method that returned an int, I'd use a value of something that wouldn't normally be returned by that method to indicate failure, such as a -1.
    ~~Bonnie DeWitt [C# MVP]
    That's something very very important to keep in mind. Can save you from a lot of headaches!
    So if you have an int function and it might return NULL, if you are doing Math with the return value you can use it directly, but if you're assigning it to another variable you have to use .Value?
    Thanks

  • What is the best way of converting everything in a result set into a string

    hello folks
    What do you think is the best way of converting everything in a resultset into a string???
    At the moment I'm using
    rs.getString(i);
    everywhere (no matter if the underlying datatype is a date or whatever..) it converts automatically evertything expect NULL into a valid string.
    Are there better (simple to use..) ways?

    I don't see a big switch construct. How about trying the following:
    Call this method from your original method by passing the resultset obtained.
    public String[] convert(ResultSet rs) {
         int col = ((ResultSetMetaData) rs.getMetaData()).getColumnCount();
         String[] record = new String[col];
         int i=0;
         while(rs.next()) {
              if(rs.wasNull()) record[i] = new String();
              else record[i] = rs.getString(i);
              i++;
         return record;
    iDriZ

  • What is the best way to execute immediate particular sql stored in a table

    I have a string variable containing row_ids eg "12,24,35,23"
    and a table
    row_id, sql
    1 , "insert into some_table values(23,'Happy');"
    6 , "insert into some_other_table values(24,'Sad');"
    12 , "insert into some_table values(23,'Crazzzy');"
    15 , "insert into some_other_table values(23,'Old');"
    23 , "insert into another_table values(23,'Left');"
    24 , "insert into stuff_table values(23,'Gold');"
    30 , "insert into old_table values(23,'Even');"
    35 , "insert into archive_table values(23,"True");"
    And I need to write a plsql function that takes the list of row_ids as an argument and executes the sql statements stored in the table that matches.
    I am trying a combination of cursor and execute immediate statements to do it at the moment but suspect I am being very inefficient. So any suggestions or examples of similar code anyone knows about would be hugely appreciated.
    Cheers
    Reuben

    Not sure why anyone would be doing such a thing as storing their SQL in a table and wanting to dynamically execute it (generally this is bad practice), but if you must...
    SQL> select * from testdata;
        SQL_ID SQL_TEXT
             1 insert into some_table values(23,'Happy');
             6 insert into some_other_table values(24,'Sad');
            12 insert into some_table values(23,'Crazzzy');
            15 insert into some_other_table values(23,'Old');
            23 insert into another_table values(23,'Left');
            24 insert into stuff_table values(23,'Gold');
            30 insert into old_table values(23,'Even');
            35 insert into archive_table values(23,'True');
    8 rows selected.
    SQL> set serverout on
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2    v_ids VARCHAR2(4000) := '12,24,35,23';
      3    CURSOR cur_fetch IS
      4      SELECT sql_text
      5      FROM   testdata
      6      WHERE  sql_id IN (SELECT TO_NUMBER(REGEXP_SUBSTR (v_ids, '[^,]+', 1, rownum))
      7                        FROM   DUAL
      8                        CONNECT BY ROWNUM <= length(regexp_replace(v_ids,'[^,]*'))+1);
      9  BEGIN
    10    FOR s IN cur_fetch
    11    LOOP
    12      DBMS_OUTPUT.PUT_LINE(s.sql_text); -- For demo purposes show the sql text
    13      -- EXECUTE IMMEDIATE s.sql_text; -- In reality, uncomment this to execute the sql text
    14    END LOOP;
    15* END;
    16  /
    insert into some_table values(23,'Crazzzy');
    insert into another_table values(23,'Left');
    insert into stuff_table values(23,'Gold');
    insert into archive_table values(23,'True');
    PL/SQL procedure successfully completed.
    SQL>

  • What is the best way to create a bookmark for a returning user??

    Hello all... hello again Steve...I am back with another question- what is the best way to implement a bookmark system so returning users can pick up where they left off in an AW lesson? I have tried the usual internet searches, always do, but the few samples/answers I have found were AW5, not much help...
    I have a dozen or so maps attached to my framework, I would like a user to return to the last map he viewed before closing. (My AW is communicating fine with an Access database, so if passing a variable to Access and then back to AW when the lesson starts is on the right track, let me know...) If the answer here is too complicated, maybe nudge me in the right direction and I will dive back in.
    Thanks in advance to anyone who has some guidance, I really do appreciate it!
    Terry

    Try this outline, see if it helps ...
    Grab a reference to the Map as you enter it, then save that to the database when you leave.
    You want something that will give you the equivalent to a page number - if you have 7 maps hanging off the Framework, and the user is in the 6th map when he exits, you want to save the number 6.
    There are scores of ways to do this, but probably the easiest is just to attach a calc to each map that has this code
    (I don't have Authorwar handy to check syntax, so you should check!)
    BookMarkPage = ChildIDtoNum(IconParent(IconID), IconID) <-- tells Authorware to return the "page number" of the current map
    Save BookMarkPage to your Access database on exit .
    On return, read the bookmark back into BookMarkPage, ask the user if he wants to return to bookmark. If yes, use a calculated navigation that uses
    ChildNumToID(@the name of your Framework or it's ID, BookMarkPage)
    Note that you could wrangle something similar by saving the IconID of your Map, or the IconTitle, but both of these can break if you ever update your file by adding or removing pages, renaming them etc. With this method, all you need is a simple page count check that ensures that you are not trying to nav to a page number that does not exist (use IconNumChildren).
    Steve

  • What data does SNMP return and what is the best way to explore it?

    Hi All
    I have some queries about using SNMP on Cisco devices.
    1. What is the best way to get an idea of what data MIBs can return?
    I have entered the commmand "show snmp mib". However, the number of MIBs generated is huge!
    2. Can you enter a command on the Cisco device itself that returns snmp data?
    e.g. if I want to see what data a MIB entry returns, can I interrogate it on the Cisco device itself rather than having to rely on network management software?
    The reason I ask is that we are currently looking for Network Management Software. However, I have no idea what data SNMP can return, therefore don't know if what the Management Software offers is comprehensive or not.
    Any suggestions on how best to get an idea the data SNMP can generate plus any other suggestions are very welcome!
    Thanks
    John

    Generally speaking, snmp can query about any parameter of the system. An enterprise class device has almost all conceivable parameters instrumented thus. A device's inventory (chassis, cards, ports, power supplies, software image, etc.) and the state of its interfaces and traffic they are carrying are among the primary ones.
    You can query a device's snmp variables remotely "by hand" using an open source distribution of a tool like snmpwalk. You need to know what you're looking for - i.e., the exact oid (object ID) string or else you get a long reply like you alluded to. It also helps to have the actual MIB you are querying against locally so that the output you get will be human-readable. Otherwise you'll get long numeric strings (the snmp oid) followed by alphanumeric values which may or may not make sense at first glance depending on the oid being queried. A MIB's purpose is to add that abstraction layer / interpretation to make the output more useful to the operator.
    The purpose of an NMS (very generally speaking) is to give an even higher layer of abstraction to organize the querying and reporting of all these various data into a useful system with dashboards, graphs, reports etc.

  • What is the best way to present favorite photos for a group of people

    What is the best way to present your favorite photos for a group presentation?? I use iPhoto library. I also have Aperture downloaded on my iMac. Not too familiar with Aperture.  It is for a milestone birthday.

    I think it's easiest to work from iPhoto. When I had to do a similar presentation for a birthday bash, I loaded the picts from my camera and some from my computer into iPhoto on a relative's MacBook Pro avalable at the site. It did not take a lot of time or trouble.
    iPhoto allows fairly easy options for presenting the slide show , including various transitions and putting a sound track underneath.
    Regardless of whether the presentation was or wasn't  less elegant than what some more expensive software could do, the attendees loved what we did for that bash.
    Never used Aperture so I don't know what it can do. You could ask in the Aperature forums here:
    Aperture

  • What is the best way of setting up Family Sharing?

    I just bought my son an iPad Mini and I am trying to decide on what is the best way of setting it up for him. The one thing I do know is that I do NOT want all the content that is my iPhone 6 to pop up on his iPad Mini. I want his iPad to be used for his games and educational stuff and his own music. I don't mind setting up a family photo album and share photos with the family. So is the Family Sharing option the best way of doing this based on what I just mentioned? Do I set him up with his own Apple ID? If so will everything still be based off my account so he won't have to create his own iTunes Library?
    I always use iTunes gift cards to purchase music and content. Will I be able to continue to use them even if I want to put some new content on his iPad and not my iPhone? Do I enter in his Apple ID info. Can you restrict certain family members to just certain things for example you only want to share photos with one person whereas you might want to share your music with another family member?
    Any suggestions on the best way of setting this up would great!
    Thanks!

    Hi DVX100Shooter,
    Congratulations on getting your son a new iPad, I am sure he will enjoy it. 
    Family Sharing is one way of managing both purchases and content between members of a related group of people. Each member must have their own Apple ID. You can choose what music you wish to share with the family from your own account. See this article -
    OS X Yosemite: Share purchases with your family
    In particular the section titled Hide a purchase from other family members
    The music library on your son's iPad is separate from yours, but under Family Sharing you agree to pay for all purchases made through the iTunes store. If you wish to control what is purchased you can set up the Ask to Buy option for any family member under adult age in your location. See this article for details -
    Request and make purchases with Ask to Buy - Apple Support
    Gift cards may not be used for billing of purchases under family sharing, with the exception that a family member may use gift cards to purchase their own content. See this article for information about Family Sharing billing policies -
    Family purchases and payments - Apple Support
    The shared family photo album is available to all family members.
    Family Sharing - Apple Support
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

  • I had to reset my iphone 5 today because of software issues. what is the best way to restore all my apps?

    I had to reset my iphone 5 because of corrupt software issues. now I am trying to restore my apps. So are returning. Some are not. Some are making me pay for them again! What is the best way to restor all the apps?

    Sync them from your computer back to the iphone

  • What is the best way to clone a form field in BC

    Hi,
    What is the best way to clone a form field in BC.  I tried using jquery .clone.  It works fine on other forms for me but not on the BC forms, why? is it just me?  Any help would be great. Thanks

    I mean, duplicate a field with the click of a button.
    I think this should work, but it's not and  I am linked to the jquery library in the head of my page.
    <script type="text/javascript">
    $(document).ready(
      function() {
        $('input#tmpAddRow').click(
          function($e) {
            $e.preventDefault();
            $('tr#tmp').clone(true).removeAttr('id').appendTo('tbody');
        $('tr input[type=text]').focus(
          function() {
            $(this).addClass('myFocused');  
        ).blur(
          function() {
            $(this).removeClass('myFocused');
        </script>
    <img alt="" style="border: 0px solid; width: 200px; height: 134px; float: left;" src="/images/pv logo 3d.png" />
    <h3 style="text-align: center; color: #0000ff; text-shadow: #999999 0px 1px 5px;">Member Directory Listing</h3>
    <p style="text-align: center;">If you would like to be listed in the Pine Valley Middle School Directory, please fill out this form.  Only fill out the areas you would like to show up in our Directory.</p>
    <div style="margin-left: 130px;" class="form_bg">
    <form action="/CustomContentProcess.aspx?CCID=5656&amp;OID={module_oid}&amp;OTYPE={module_otype }" method="post" enctype="multipart/form-data" onsubmit="return checkWholeForm45842(this)" name="catcustomcontentform45842">
        <table cellspacing="0" cellpadding="2" border="0" class="webform">
            <tbody>
                <tr>
                    <td id="tmp"><label for="ItemName">First Name</label><br />
                    <input type="text" value="{module_firstname}" maxlength="255" id="ItemName" name="ItemName" class="cat_textbox_small" /><br />
                    <input type="button" id="tmpAddRow" value="Add a Row" />
                    </td>
                </tr>
                <tr>
                    <td><label for="CAT_Custom_131512">Last Name</label><br />
                    <input type="text" value="{module_lastname}" class="cat_textbox" id="CAT_Custom_131512" name="CAT_Custom_131512" maxlength="1024" /></td>
                </tr>
                <tr>
                    <td><label for="CAT_Custom_131509">Number</label><br />
                    <input type="text" value="{module_homephone}" class="cat_textbox" id="CAT_Custom_131509" name="CAT_Custom_131509" maxlength="1024" />
                    </td>
                </tr>
                <tr>
                    <td><label for="CAT_Custom_131510">Email</label><br />
                    <input type="text" value="{module_emailaddress}" class="cat_textbox" id="CAT_Custom_131510" name="CAT_Custom_131510" maxlength="1024" /></td>
                </tr>
                <tr>
                    <td><label for="ItemAddress">Address</label><br />
                    <input type="text" value="{module_homeaddress}" maxlength="500" class="cat_textbox" id="ItemAddress" name="ItemAddress" />
                    </td>
                </tr>
                <tr>
                    <td><label for="ItemCity">City</label><br />
                    <input type="text" value="{module_homecity}" maxlength="255" class="cat_textbox" id="ItemCity" name="ItemCity" /></td>
                </tr>
                <tr>
                    <td><label for="ItemState">State</label><br />
                    <input type="text" value="{module_homestate}" maxlength="255" class="cat_textbox" id="ItemState" name="ItemState" />
                    </td>
                </tr>
                <tr>
                    <td><label for="ItemZip">Zipcode/Postcode</label><br />
                    <input type="text" value="{module_homezip}" maxlength="255" class="cat_textbox" id="ItemZip" name="ItemZip" /></td>
                </tr>
                <tr>
                    <td class="hidden"><label for="FirstName">First Name</label><br />
                    <input type="text" value="{module_firstname}" class="cat_textbox" id="FirstName" name="CAT_Custom_131511" maxlength="1024" /></td>
                </tr>
                <tr>
                    <td><input type="submit" id="catcustomcontentbutton" value="Submit" class="cat_button" /></td>
                </tr>
            </tbody>
        </table>
        <script type="text/javascript" src="/CatalystScripts/ValidationFunctions.js"></script>
        <script type="text/javascript" src="/CatalystScripts/Java_DatePicker.js"></script>
        <script type="text/javascript">
    //<![CDATA[
    var submitcount45842 = 0;function checkWholeForm45842(theForm){var why = "";if (theForm.ItemName) why += isEmpty(theForm.ItemName.value, "Item Name");if (theForm.Days) why += isNumericIfVisible(theForm.Days, "days"); if (why != ""){alert(why);return false;}if(submitcount45842 == 0){submitcount45842++;theForm.submit();return false;}else{alert("Form submission is in progress.");return false;}}
    //]]>
    </script>
        <script type="text/javascript">
        jQuery("#ItemName").blur(function(){
            jQuery("#FirstName").val(jQuery("#ItemName").val());
    </script>
    </form>
    </div>

  • What is the best way to organize a tree-like structure of constants?

    Hello everone!
    Need help with organizing my constants structrure.
    I have several tables, and each of them need a list of column names to define the fields returned after query, and also a corresponding list of hashmap keys because that columnnames are ugly. Hashmap is where I store the result of searching through the table. This question is not about JDBC because I search through tables via COM interface, no JDBC ResultSets and other stuff here.
    Finally, for each table I have two constant lists and I have a list of tables. What is the best way to store this?
    My first idea was to create a enum and store column data in it as String array attributes: String[] columnNames; etc.
    But in this case I cannot use each column and key separately.
    Another option is to create two separate enums for each table: columnNames enum and keys enum. That doesn't look great also.
    The third option is to create inner class for each table and store two enums in each of that classes.
    Also I can store all data in hashmaps, Strings etc.
    (1) Finally, from your experience, what is the best way to organize all that stuff?
    (2) I have heard that smart Java programmer should avoid using the enums by any means. Do you agree?
    (3) Generally what will you prefer when creating a constant which has two values: two final Integers or enum?
    Edited by: Dmitry_MSK on Jul 8, 2010 5:22 AM

    I'm not sure why you don't just invent a generic data structure (e.g., table name, list of column names and aliases of column names) such as:
    class QueryMetaData {
      private final String tableName;
      private final String[] columnNames;
      private final String[] columnAliases;
    }Read into the above structure from a properties file, database table, etc. You can store meta-data itself in places other than enum constants, particularly if would like to change the meta-data without requiring a new build of your application.
    That having been said, WRT to your specific questions:
    (1) Finally, from your experience, what is the best way to organize all that stuff?See above
    (2) I have heard that smart Java programmer should avoid using the enums by any means. Do you agree?Enums are better than simple constants using int or String or something similar. If there are known, discrete values unlikely to change frequently, I see no issues with an enum. They improve the readability of code, and there are enough syntactic sugar features in the language (switch statements come to mind) to make them appealing.
    (3) Generally what will you prefer when creating a constant which has two values: two final Integers or enum?
    See above. Enums were introduced (in large part) to do away with storing constants as integers.
    - Saish

  • What is the best way of dealing with an "implicit coercion" of an array to a sprite?

    Hello everyone!
         With continued help from this forum I am getting closer to having a working program. I look forward to being able to help others like myself once I finish learning the AS3 ropes.
         I will briefly explain what I am trying to achieve and then follow it up with my question.
    Background
         I have created a 12 x 9 random number grid that populates each cell with a corresponding image based on each cell's numeric value. I have also created a shuffle button that randomizes the numbers in the grid. The problem I am running into is getting my button-click event to clear the current images off the grid in order to assign new ones (i.e. deleting the display stack objects in order to place news ones in the same locations).
    Question
         My question is this: what is the best way to handle an implicit coercion from an array to a sprite? I have pasted my entire code below so that you can see how the functions are supposed to work together. My trouble apparently lies with not being able to use an array value with a sprite (the sprite represents the actual arrangement of the grid on the display stack while the array starts out as a number than gets assigned an image which should be passed to the sprite).
    ============================================================================
    package 
    import flash.display.MovieClip;
    import flash.display.DisplayObject;
    import flash.events.MouseEvent;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.utils.getDefinitionByName;
    public class Blanko extends MovieClip
          // Holds 12*9 grid of cells.
          var grid:Sprite;
          // Holds the shuffle button.
          var shuffleButton:Sprite;
          // Equals 12 columns, 9 rows.
          var cols:int = 12;
          var rows:int = 9;
          // Equals number of cells in grid (108).
          var cells:int = cols * rows;
          // Sets cell width and height to 40 pixels.
          var cellW:int = 40;
          var cellH:int = 40;
          // Holds 108 cell images.
          var imageArray:Array = [];
          // Holds 108 numerical values for the cells in the grid.
          var cellNumbers:Array = [];
          // Constructor calls "generateGrid" and "makeShuffleButton" functions.
          public function Blanko()
               generateGrid();
               makeShuffleButton();
      // Creates and displays the 12*9 grid.
      private function generateGrid():void
           grid = new Sprite;
           var i:int = 0;
           for (i = 0; i < cells; i++)
                cellNumbers.push(i % 9 + 1);
           trace("Before shuffle: ", cellNumbers);
           shuffleCells(cellNumbers);
           trace("After shuffle: ", cellNumbers);
           var _cell:Sprite;
           for (i = 0; i < cells; i++)
                // This next line is where the implicit coercion occurs. "_cell" is a sprite that tries
                   to temporarily equal an array value.
                _cell = drawCells(cellNumbers[i]);
                _cell.x = (i % cols) * cellW;
                _cell.y = (i / cols) * cellH;
                grid.addChild(_cell);
      // Creates a "shuffle" button and adds an on-click mouse event.
      private function makeShuffleButton():void
           var _label:TextField = new TextField();
           _label.autoSize = "center";
           TextField(_label).multiline = TextField(_label).wordWrap = false;
           TextField(_label).defaultTextFormat = new TextFormat("Arial", 11, 0xFFFFFF, "bold");
           _label.text = "SHUFFLE";
           _label.x = 4;
           _label.y = 2;
           shuffleButton = new Sprite();
           shuffleButton.graphics.beginFill(0x484848);
           shuffleButton.graphics.drawRoundRect(0, 0, _label.width + _label.x * 2, _label.height +
                                                _label.y * 2, 10);
           shuffleButton.addChild(_label);
           shuffleButton.buttonMode = shuffleButton.useHandCursor = true;
           shuffleButton.mouseChildren = false;
           shuffleButton.x = grid.x + 30 + grid.width - shuffleButton.width;
           shuffleButton.y = grid.y + grid.height + 10;
           this.addChild(shuffleButton);
           shuffleButton.addEventListener(MouseEvent.CLICK, onShuffleButtonClick);
      // Clears cell images, shuffles their numbers and then assigns them new images.
      private function onShuffleButtonClick():void
       eraseCells();
       shuffleCells(cellNumbers);
       trace("After shuffle: ", cellNumbers);
       for (var i:int = 0; i < cells; i++)
        drawCells(cellNumbers[i]);
      // Removes any existing cell images from the display stack.
      private function eraseCells(): void
       while (imageArray.numChildren > 0)
        imageArray.removeChildAt(0);
      // Shuffles cell numbers (randomizes array).
      private function shuffleCells(_array:Array):void
       var _number:int = 0;
       var _a:int = 0;
       var _b:int = 0;
       var _rand:int = 0;
       for (var i:int = _array.length - 1; i > 0; i--)
        _rand = Math.random() * (i - 1);
        _a = _array[i];
        _b = _array[_rand];
        _array[i] = _b;
        _array[_rand] = _a;
      // Retrieves and assigns a custom image to a cell based on its numerical value.
      private function drawCells(_numeral:int):Array
       var _classRef:Class = Class(getDefinitionByName("skin" + _numeral));
       _classRef.x = 30;
       imageArray.push(_classRef);
       imageArray.addChild(_classRef);
       return imageArray;
    ===========================================================================
         Any help with this is greatly appreciated. Thanks!

    Rothrock,
         Thank you for the reply. Let me address a few things here in the hopes of allowing you (and others) to better understand my reasoning for doing things in this manner (admittedly, there is probably a much better/easier approach to what I am trying to accomplish which is one of the things I hope to learn/discover from these posts).
         The elements inside my "imageArray" are all individual graphics that I had imported, changed their type to movie clips using .Sprite as their base class (instead of .MovieClip) and then saved as classes. The reason I did this was because the classes could then be referenced via "getDefinitionByName" by each cell value that was being passed to it. In this grid every number from 1 to 9 appears randomly 12 times each (making the 108 cells which populate the grid). I did not, at the time (nor do I now), know of a better method to implement for making sure that each image appears in the cell that has the corresponding value (i.e. every time a cell has the value of 8 then the custom graphic/class "skin8" will be assigned to it so that the viewer will be able to see a more aesthetically pleasing numerical representation, that is to say a slightly more fancy looking number with a picture behind it). I was advised to store these images in an array so that I could destroy them when I reshuffle the grid in order to make room for the new images (but I probably messed up the instructions).
         If the "drawCell" function only returns a sprite rather than the image array itself, doesn't that mean that my "eraseCells" function won't be able to delete the array's children as their values weren't first returned to the global variable which my erasing function is accessing?
         As for the function name "drawCells," you have to keep in mind that a) my program has been redesigned in stages as I add new functionality/remove old functionality (such as removing text labels and formatting which were originally in this function) and b) that my program is called "Blanko."
         I will try and attach an Illustrator exported JPG file that contains the image I am using as the class "skin7" just to give you an example of what I'm trying to use as labels (although it won't let me insert it here in this post, so I will try it in the next post).
    Thank you for your help!

  • What is the best way to kill/stop a data load?

    Hi.
    What is the best way to kill/stop a data load?
    I have a data load from my QA R/3 system that is extracting 115.000.000+ records. The problem is that the selection in the function module used in the data source does not work, and the problem was not detected because of the nature of the data on the development system.
    I could kill processes owned by my background user (on both R/3 and BW) but I risk killing other loads, and sometimes the job seems to restart if I just try to kill processes. If I remove transactional RFCs in SM58 the load does not terminate; I only skip one or more datapackages. I have also tried to change the QM-status in the monitor to red, but that does not stop the load either...
    So isn't there a nice fool-proof way of stopping a dataload?
    Best regards,
    Christian Frier

    Hi,
    There r 2 ways to kill the job.
    One is using transation RSMO locate the job and display the status tab double click on the yellow light that is shown on the line total, a pop will come 'set overall status ' is displayed select the desired status that is red and save it. Then return to the monitor page and select the header tab double ckick on the data target right click and then goto 'manage',there should be request sitting there probably with yellow lights , highlight the line with the faulty request click the delete button then click refresh button.
    Second is goto SM37 and click on the active selection and enter the jobname and then click excute the particulr job should appear highlight the jobname then click on the stop iconthat appears on the taskbar( 3 rd from left)
    hope it is clear.
    Regards-
    Siddhu

  • What's the best way to deal with floating point errors?

    What's the best way to deal with the decimal number errors in Flex?
    Lets say I have:
    var number1:Number = 1.1;
    var number2:Number = 1;
    var result:Number = number1 - number2;
    trace(result);
    I get "0.10000000000000009".
    What's the best way to deal with this so that i get the right result?
    Using the trick: result = Math.round( result * Math.pow(10,13) ) / Math.pow(10,13); is not useful as such when using big numbers.
    For example, If number1 = 100000000001.1, and number2 = 0.2, I get "100000000000.90001" as result. The previous rounding fixes rounding errors after 13th decimal, but here the first rounding errors come after 4 digits.
    The toPrecision method in Number and NumberFormatter dont seem be of use by themselves because of the same reason.
    So I'd have to check how big the number is, and then round the number based on that.
    So far I've constructed a method that does that with logarithms like this:
    public function floatFix(number:Number):Number{
          var precision:int = 14-Math.floor(Math.log(Math.abs(number))*Math.LOG10E);
          var precisionFactor:Number = Math.pow(10, precision);
          return Math.round(Number(number*precisionFactor))/precisionFactor;
    It just seems rather odd that one would have to create and use something like that to just count 1.1-1; There's a lot of calculating in that method, and i'm guessing that having to use that in a loop could slow down a program quite a bit.
    I think there really should be a pre-built method in flex for something like this, but I can't find any.
    Anyone know any better/faster ways?

    Use the application server database pooling services to create a datasource that can be access using JNDI.
    Move the database access code to a Servlet so that a JSP submits a form to the Servlet that does the database access and packages the data into a bean which is passed to another JSP to be displayed.

  • What is the best way to sync multiple collections of contacts among multiple users?

    (I originally submitted this question under the "Mac OS X Technologies" section, but got no response. I'm submitting a duplicate here because this is where all the smart folks are! My apologies that my question is only partially related to OS X Server . . . )
    What is the best way to sync multiple collections of contacts among multiple users on iOS and OS X?
    For example, suppose I have three collections of contacts: Bob's, Sally's, and Common. I want Bob to be able to access and sync Bob's contacts and Common contacts, and Sally to access and sync Sally's contacts and Common contacts. Bob and Sally never need to access or sync each other's contacts. Bob and Sally would both sync and share contacts in Common.
    How would I best implement this? It's my understanding I have three options for managing contacts across iOS and OS X: 1. iCloud accounts, 2. Install OS X server, or 3. Install and manage Darwin CardDAV directly. Which method would best support what I wish to do?
    I am a seasoned Unix geek well versed in the terminal, so I am prepared to get my hands dirty as much as necessary to achieve what I want. Also, it is sufficient if syncing takes place over WiFi on the local network, in fact, that is desirable versus syncing over the cloud.

    Thanks for your reply Nick101. I see my example was oversimplified. When I say "multiple groups of contacts over multiple users" I'm really referring to N groups of contacts over N users.
    So I need to add Fred, who can access and sync Bob's contacts, Sally's contacts, and Common contacts, as well as Fred's contacts. Can I do it with OS X server?
    You mention you keep your and your partner's contacts administered locally. What keeps you from administering them through OS X server as well?
    I am guessing this can all somehow be accomplished with multiple contact accounts, but I can't find any information on the web explicitly describing this.

Maybe you are looking for

  • Is there a way to install Mountain Lion from my laptop to my MacPro Tower without a disc?

    I erased my drive on my mac thinking I could migrate my stuff from my Mac Mini to my Mac Pro Tower.  The mac mini won't let me migrate it. The drives aren't being recognized in Migration Assistant (while being hooked up via firewire 800).  I was wond

  • Photos in iPhoto are suddenly VERY Dark

    I have over 4,000 photos in my iPhoto library and up until a few days ago everything seemed to be working perfectly. But all of a sudden - literally one minute the application was open and everything was working fine and the next minute all my photos

  • How to Resume "Normal" Style in Mail?

    I frequently (i.e., always) encounter a very annoying feature in mail from which I'm unable to figure out how to extricate myself once the "trigger" is in place! Whenever I copy and paste an item into a mail composition, I find that the style, shadin

  • Agent assignment in Workflows using Rules.

    what is Agent assignment in Workflows using Rules.

  • Vmfusion 3 and Mac - Urgent can't use new mac

    I tried to log into my brand new imac 27" this after and was shocked to see that windows had been launched. I HATE vm fusion - I have tried everything to shut it down and get back to just the Mac OS and nothing has worked. I have tried the VM Suspend