NullPointerException when adding object in a Collection

Hello,
I have this code:
----code----
Group group = new Group("test");
Collection col = null;
col.add(group);
----code----
The last line produces a NullPointerException.
But group is a valid object.
I don't understand why.
Could you help me?
Thanks
Sylvain

As a side note,
If you are fairly new to Java, then its worth reading about the Collections API as you'll find yourself using it a lot. Its also a create example of how powerful interfaces are.
In your code, try and make the compile time object a Collection and always pass the Collection interface around. (i.e. make the return type and parameter type of your methods Collection). This should let you do all the stuff you need e.g. getting objects out, putting them in and getting an iterator.
Only tie the Colection to a particular implementation at Runtime, e.g.
Collection c = new ArrayList();
is a lot better than
ArrayList c = new ArrayList();
That way, if you decide later that a HashSet() is better than an ArrayList() for your purpose, you only need to change one line of code. HashSet still implements Collection so all your methods will still work.
Hurrah for maintainable code!
As you can tell, I like interfaces

Similar Messages

  • NullPointerException when adding an object into a Vector Class

    So here is the code:
    package Image;
    import java.io.Serializable;
    import java.util.Vector;
    public class Album implements Serializable{
    private String name;
    private String password;
    Vector<ImageClass> allImages;
    public Album( String name, String password, Vector<ImageClass> allImages) {
    this.name = name;
    this.password = password;
    this.allImages = allImages;
    public Album() {
    public Vector<ImageClass> getAllImages() {
    return allImages;
    public void setAllImages(Vector<ImageClass> allImages) {
    this.allImages = allImages;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    public String getPassword() {
    return password;
    public void setPassword(String password) {
    this.password = password;
    public void addIC(ImageClass ic){
    allImages.add(ic);
    public ImageClass getIC(int pos){
    ImageClass ic = allImages.get(pos);
    return ic;
    Now I got an NullPointerException when I call the getIC Method from another class of another package
    Here is the part of code of that class.
    private void SaveMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                            
    ImageClass ic = new ImageClass();
    ic.setTitle(ImageTextField.getText());
    ic.setDescription(DescriptionTextArea.getText());
    try {
    ic.setReferenceNumber(Integer.parseInt(ReferenceTextField.getText()));
    } catch (NumberFormatException nfe) {
    JOptionPane.showMessageDialog(null, "Reference Number is not in a correct format");
    try {
    ic.setDate(new SimpleDateFormat("dd/MM/yyyy").parse(DateTextField.getText(), new ParsePosition(0)));
    } catch (IllegalArgumentException iae) {
    JOptionPane.showMessageDialog(null, "Date is not in correct format");
    ic.setImageData(imageData);
    if(a==null){
    JOptionPane.showMessageDialog(this,"Please, create or open an Album");
    }else{
    a.addIC(ic);
    try{
    ObjectOutputStream oos;
    FileOutputStream fos = new FileOutputStream(album, true);
    oos = new ObjectOutputStream(fos);
    oos.writeObject(a);
    oos.flush();
    oos.close();
    }catch(FileNotFoundException fnfe){
    fnfe.printStackTrace();
    }catch(IOException ioe){
    ioe.printStackTrace();
    }

    h1. The Ubiquitous Newbie Tips
    * DON'T SHOUT!!!
    * Homework dumps will be flamed mercilessly. [Feelin' lucky, punk? Well, do ya'?|http://www.youtube.com/watch?v=1-0BVT4cqGY]
    * Have a quick scan through the [Forum FAQ's|http://wikis.sun.com/display/SunForums/Forums.sun.com+FAQ].
    h5. Ask a good question
    * Don't forget to actually ask a question. No, The subject line doesn't count.
    * Don't even talk to me until you've:
        (a) [googled it|http://www.google.com.au/] and
        (b) had a squizzy at the [Java Cheat Sheet|http://mindprod.com/jgloss/jcheat.html] and
        (c) looked it up in [Sun's Java Tutorials|http://java.sun.com/docs/books/tutorial/] and
        (d) read the relevant section of the [API Docs|http://java.sun.com/javase/6/docs/api/index-files/index-1.html] and maybe even
        (e) referred to the JLS for "advanced" questions.
    * [Good questions|http://www.catb.org/~esr/faqs/smart-questions.html#intro] get better Answers. It's a fact. Trust me on this one.
        - Lots of regulars on these forums simply don't read badly written questions. It's just too frustrating.
          - FFS spare us the SMS and L33t speak! Pull your pants up, and get a hair cut!
        - Often you discover your own mistake whilst forming a "Good question".
        - Often you discover that you where trying to answer "[the wrong question|http://blog.aisleten.com/2008/11/20/youre-asking-the-wrong-question/]".
        - Many of the regulars on these forums will bend over backwards to help with a "Good question",
          especially to a nuggetty problem, because they're interested in the answer.
    * Improve your chances of getting laid tonight by writing an SSCCE
        - For you normal people, That's a: Short Self-Contained Compilable (Correct) Example.
        - Short is sweet: No-one wants to wade through 5000 lines to find your syntax errors!
        - Often you discover your own mistake whilst writing an SSCCE.
        - Often you solve your own problem whilst preparing the SSCCE.
        - Solving your own problem yields a sense of accomplishment, which makes you smarter ;-)
    h5. Formatting Matters
    * Post your code between a pair of &#123;code} tags
        - That is: &#123;code} ... your code goes here ... &#123;code}
        - This makes your code easier to read by preserving whitespace and highlighting java syntax.
        - Copy&paste your source code directly from your editor. The forum editor basically sucks.
        - The forums tabwidth is 8, as per [the java coding conventions|http://java.sun.com/docs/codeconv/].
          - Indents will go jagged if your tabwidth!=8 and you've mixed tabs and spaces.
          - Indentation is essential to following program code.
          - Long lines (say > 132 chars) should be wrapped.
    * Post your error messages between a pair of &#123;code} tags:
        - That is: &#123;code} ... errors here ... &#123;code}
        - OR: &#91;pre]&#123;noformat} ... errors here ... &#123;noformat}&#91;/pre]
        - To make it easier for us to find, Mark the erroneous line(s) in your source-code. For example:
            System.out.println("Your momma!); // <<<< ERROR 1
        - Note that error messages are rendered basically useless if the code has been
          modified AT ALL since the error message was produced.
        - Here's [How to read a stacktrace|http://www.0xcafefeed.com/2004/06/of-thread-dumps-and-stack-traces/].
    * The forum editor has a "Preview" pane. Use it.
        - If you're new around here you'll probably find the "Rich Text" view is easier to use.
        - WARNING: Swapping from "Plain Text" view to "Rich Text" scrambles the markup!
        - To see how a posted "special effect" is done, click reply then click the quote button.
    If you (the newbie) have covered these bases *you deserve, and can therefore expect, GOOD answers!*
    h1. The pledge!
    We the New To Java regulars do hereby pledge to refrain from flaming anybody, no matter how gumbyish the question, if the OP has demonstrably tried to cover these bases. The rest are fair game.

  • Java.lang.NullPointerException when added LOV to column

    Hi,
    I am getting java.lang.NullPointerException error when opening web adi spreadsheet (before it is even formatted) since I added LOV to one of the columns. I did following update:
    UPDATE bne_interface_cols_b
    SET val_id_col = 'LOOKUP_CODE',
    val_mean_col = 'MEANING',
    val_desc_col = 'DESCRIPTION',
    val_type = 'TABLE',
    lov_type = 'POPLIST',
    val_obj_name = 'FND_LOOKUPS',
    val_addl_w_c = 'LOOKUP_TYPE = ''SOURCE'''
    WHERE interface_col_name = 'X_RELEASE_LOOKUP_CODE'
    AND application_id = 200
    AND interface_code = 'GENERAL_101_INTF';
    BNE log is showing following:
    CRITICAL ERROR BneAbstractXMLServlet.doRequest(), fatal exception: java.lang.NullPointerException
    CRITICAL ERROR java.lang.NullPointerException
         at oracle.apps.bne.repository.BneInterfaceCol.buildTableValidationQuery(BneInterfaceCol.java:684)
         at oracle.apps.bne.repository.BneInterfaceCol.getTableLovQuery(BneInterfaceCol.java:582)
         at oracle.apps.bne.repository.BneInterface.getTableLovQuery(BneInterface.java:771)
         at oracle.apps.bne.repository.BneIntegrator.getTableLovQuery(BneIntegrator.java:927)
         at oracle.apps.bne.repository.BneRenderableLayout.loadPopListData(BneRenderableLayout.java:1509)
         at oracle.apps.bne.repository.BneRenderableLayout.loadLayoutColumnData(BneRenderableLayout.java:665)
         at oracle.apps.bne.repository.BneRenderableLayout.loadLayoutHierarchyData(BneRenderableLayout.java:480)
         at oracle.apps.bne.repository.BneRenderableLayout.<init>(BneRenderableLayout.java:116)
         at oracle.apps.bne.repository.BneLayout.getRenderableLayout(BneLayout.java:2047)
         at oracle.apps.bne.integrator.document.BneOAExcelViewer.validateParameters(BneOAExcelViewer.java:593)
         at oracle.apps.bne.integrator.document.BneOAExcelViewer.getViewerBean(BneOAExcelViewer.java:234)
         at oracle.apps.bne.integrator.document.BneAbstractViewer.toXML(BneAbstractViewer.java:468)
         at oracle.apps.bne.integrator.document.BneViewerXMLService.handleRequest(BneViewerXMLService.java:177)
         at oracle.apps.bne.framework.BneAbstractXMLServlet.doRequest(BneAbstractXMLServlet.java:613)
         at oracle.apps.bne.framework.BneAbstractXMLServlet.doPost(BneAbstractXMLServlet.java:172)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:521)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
         at org.apache.jserv.JServConnection.run(JServConnection.java:294)
         at java.lang.Thread.run(Thread.java:637)
    Anybody knows what the problem is? Is there any other table that has to be updated? I am on 11.5.10.
    Regards
    Piotr

    Why dont you try doing this from application.
    Enable the integrator 'Web ADI - Interface Columns Integrator' using below query :
    UPDATE bne.bne_integrators_b
    set enabled_flag = 'Y'
    where integrator_code = 'INTERFACE_COLS';
    commit;Next create a WEB ADI Form Function and do form function association. Then attach this form function to WEB ADI Menu and this integrator will be visible.
    Then call your custom integrator paiing application_id, interface_code and then populate the values/properties of individual column

  • Problem with adding objects to a collection

    Hi
    Been using this forum for a couple of years now to help me with my code, but it's the first time that I've had a problem which I couldn't find the answer for!
    I'm trying to create two classes one called Reminder and one called Engagement. The Reminder class needs to hold a list of Engagement objects, but whenever I add a new Engagement object to the ArrayList I have created in Reminder and try to retreive it I get a null value.
    If anyone can give me an idea of where I have gone wrong that would be most helpful,
    Thank you in advance,
    Steve
    Code:
    package reminder;
    import java.util.*;
    public class Reminder{
        private GregorianCalendar date       = null;
        private String            reason     = null;
        private Engagement        engagement = null;
        private List<Engagement>  appointments;
        private int year = 0;
        private int month = 0;
        private int day = 0;
        public Reminder() { //the constructor
            appointments = new ArrayList<Engagement>();
        } //end constructor
        public void add(int d, int m, int y, String r){ //this method takes an engagement object and adds it to the list
        //public void add(Engagement engagement){
            day   = d;
            month = m;
            year  = y;
            reason = r;
            appointments.add(new Engagement (new GregorianCalendar(y,m,d), reason));
            System.out.println(day + "-" + month + "-" + year);//(new Engagement (date, reason));
            appointments.add(new Engagement(new GregorianCalendar(2008,4,2), "My first appointment"));
            System.out.println("\nThere are this number of items in the list: " + appointments.size()); //this was to check the item was added
        public void getAppointments(){
            //private int arrayPosition = 0;
            //Iterator it = appointments.iterator();
            for (Iterator it = appointments.iterator(); it.hasNext();){
                System.out.println(it.next());//.appointments.toString());
                //it.next();
    package reminder;
    import java.util.*;
    import reminder.*;
    public class Engagement{
        private GregorianCalendar date = null;
        private String reason = null;
        /** Creates a new instance of Engagement */
        public Engagement(GregorianCalendar d, String r) {
            date   = d;
            reason = r;
        public String getReason() {
            System.out.println(reason);
            return null;
    public class Main { //main class to test the other classes
        /** Creates a new instance of Main */
         * @param args the command line arguments
        public static void main(String[] args) {
            Reminder reminderList = new Reminder(); //create an instance of Reminder
            reminderList.add(2,4,2008, "My first appointment");
            reminderList.add(6,10,2009, "My second appointment");
            reminderList.add(2,4,2007, "My third appointment");
            reminderList.getAppointments();
    }

    Hi Guys
    Just wanted to let you know that I have realised where I went wrong, if you look in the Engagement class there is a method called toString(); which just has a return value of null, that is why I was getting the null values!
    Sorry for wasting your time, it took me three hours to realise why it wasn't working before I contacted you and about an hour after I posted I realised what the problem was.
    One other thing... why is reminderList bad naming? I was going to call the instance reminder but because the class holds a list of objects I thought I'd call it reminderList..
    Thanks
    Steve

  • Xcode 5 crash when adding object

    During the creation of the interface error occurs (xcode crash).
    When I try to add to the project objects (such as buttons) using drag and drop objects from the library, a crash occurs.
    Process:         Xcode [1839]
    Path:            /Applications/Xcode.app/Contents/MacOS/Xcode
    Identifier:      com.apple.dt.Xcode
    Version:         5.0 (3332.25)
    Build Info:      IDEApplication-3332025000000000~2
    Code Type:       X86-64 (Native)
    Parent Process:  launchd [246]
    Responsible:     Xcode [1839]
    User ID:         501
    Crashed Thread:  0  Dispatch queue: com.apple.main-thread
    Exception Type:  EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Application Specific Information:
    ProductBuildVersion: 5A1413
    UNCAUGHT EXCEPTION (NSInvalidArchiveOperationException): Unable to produce TIFF data for bitmap NSBitmapImageRep 0x7fbd4a9a2710 Size={232, 31} ColorSpace=Device RGB colorspace BPS=8 BPP=32 Pixels=232x31 Alpha=YES Planar=NO Format=1 CurrentBacking=<CGImageRef: 0x7fbd4a867960>.  This is fatal for -[NSBitmapImageRep encodeWithCoder:].
    UserInfo: (null)
    Hints: None
    Backtrace:
      0  0x00007fff8a74f404 __exceptionPreprocess (in CoreFoundation)
      1  0x000000010cfb6c23 DVTFailureHintExceptionPreprocessor (in DVTFoundation)
      2  0x00007fff82c58e75 objc_exception_throw (in libobjc.A.dylib)
      3  0x00007fff8a74f2cc +[NSException raise:format:] (in CoreFoundation)
      4  0x00007fff8b344e2a -[NSBitmapImageRep encodeWithCoder:] (in AppKit)
      5  0x00007fff89e92427 _encodeObject (in Foundation)
      6  0x00007fff89e93a38 -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] (in Foundation)
      7  0x00007fff89e935ff -[NSArray(NSArray) encodeWithCoder:] (in Foundation)
      8  0x00007fff89e92427 _encodeObject (in Foundation)
      9  0x00007fff89e93a38 -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] (in Foundation)
    10  0x00007fff89e935ff -[NSArray(NSArray) encodeWithCoder:] (in Foundation)
    11  0x00007fff89e92427 _encodeObject (in Foundation)
    12  0x00007fff8b4c1fea __27-[NSImage encodeWithCoder:]_block_invoke534 (in AppKit)
    13  0x00007fff8af6f2c1 -[NSImage _usingRepProviderPerformBlock:] (in AppKit)
    14  0x00007fff8b4c1760 -[NSImage encodeWithCoder:] (in AppKit)
    15  0x00007fff89e92427 _encodeObject (in Foundation)
    16  0x000000011825495a (in IDEInterfaceBuilderCocoaTouchIntegration)
    17  0x00000001181cb891 (in IDEInterfaceBuilderCocoaTouchIntegration)
    18  0x00000001181bed9b (in IDEInterfaceBuilderCocoaTouchIntegration)
    19  0x00000001181c94b0 (in IDEInterfaceBuilderCocoaTouchIntegration)
    20  0x00007fff89e92427 _encodeObject (in Foundation)
    21  0x00007fff89e93a38 -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] (in Foundation)
    22  0x00007fff89e935ff -[NSArray(NSArray) encodeWithCoder:] (in Foundation)
    23  0x00007fff89e92427 _encodeObject (in Foundation)
    24  0x0000000112415be5 -[IBObjectRecord encodeWithCoder:] (in IDEInterfaceBuilderKit)
    25  0x00007fff89e92427 _encodeObject (in Foundation)
    26  0x00007fff89e93a38 -[NSKeyedArchiver _encodeArrayOfObjects:forKey:] (in Foundation)
    27  0x00007fff89e935ff -[NSArray(NSArray) encodeWithCoder:] (in Foundation)
    28  0x00007fff89e92427 _encodeObject (in Foundation)
    29  0x000000010cf84109 -[DVTMutableOrderedSet encodeWithCoder:] (in DVTFoundation)
    30  0x00007fff89e92427 _encodeObject (in Foundation)
    31  0x0000000112404fb5 -[IBObjectContainer encodeObjectsWithCoder:] (in IDEInterfaceBuilderKit)
    32  0x0000000112406cd7 -[IBObjectContainer encodeWithCoder:] (in IDEInterfaceBuilderKit)
    33  0x00007fff89e92427 _encodeObject (in Foundation)
    34  0x00000001124101f5 -[IBObjectContainer(IBObjectContainerAdditions) dataRepresentationWithArchivingDelegate:context:] (in IDEInterfaceBuilderKit)
    35  0x0000000112412d22 -[IBObjectContainer(IBObjectContainerAdditions) addObjects:withTypes:onPasteboard:forOwner:withArchivingDelegate:context:] (in IDEInterfaceBuilderKit)
    36  0x0000000112413193 -[IBObjectContainer(IBObjectContainerAdditions) putObjects:onPasteboard:forOwner:withArchivingDelegate:context:] (in IDEInterfaceBuilderKit)
    37  0x0000000112370453 -[IBDocument putObjects:onPasteboard:forOwner:context:] (in IDEInterfaceBuilderKit)
    38  0x0000000112418453 -[IBEditorCanvasFrameController dragObjects:withImage:inMouseDownEvent:mouseDraggedEvent:imageLocation:allowedOperations:editor:draggingSourceContext:] (in IDEInterfaceBuilderKit)
    39  0x0000000112441653 -[IBViewEditorCanvasFrameController dragObjects:withImage:inMouseDownEvent:mouseDraggedEvent:imageLocation:allowedOperations:editor:draggingSourceContext:] (in IDEInterfaceBuilderKit)
    40  0x0000000112438fda __113-[IBEditor dragObjects:withImage:inMouseDownEvent:mouseDraggedEvent:imageLocation:allowedOperations:dragContext:]_block_invoke (in IDEInterfaceBuilderKit)
    41  0x000000011237fb14 -[IBDocument runBlockInNewArbitrationStackEntryWithBehavior:block:] (in IDEInterfaceBuilderKit)
    42  0x0000000112438c89 -[IBEditor dragObjects:withImage:inMouseDownEvent:mouseDraggedEvent:imageLocation:allowedOperations:dragContext:] (in IDEInterfaceBuilderKit)
    43  0x0000000112458c41 -[IBViewEditor dragSelectedViewsWithMouseDown:andMouseDragged:] (in IDEInterfaceBuilderKit)
    44  0x0000000112460d80 -[IBViewEditor interceptMouseDragged:] (in IDEInterfaceBuilderKit)
    45  0x000000011246195d -[IBViewEditor interceptEvent:] (in IDEInterfaceBuilderKit)
    46  0x0000000112423895 -[IBEditorCanvasFrameController sendEvent:] (in IDEInterfaceBuilderKit)
    47  0x0000000112441557 -[IBViewEditorCanvasFrameController sendEvent:] (in IDEInterfaceBuilderKit)
    48  0x00000001123de9fa -[IBEditorCanvasFrame mouseDragged:] (in IDEInterfaceBuilderKit)
    49  0x00007fff8b18af71 -[NSWindow sendEvent:] (in AppKit)
    50  0x00007fff8b12b744 -[NSApplication sendEvent:] (in AppKit)
    51  0x000000010e02c75b -[IDEApplication sendEvent:] (in IDEKit)
    52  0x00007fff8af7ba29 -[NSApplication run] (in AppKit)
    53  0x00007fff8af66803 NSApplicationMain (in AppKit)
    54  0x00007fff8bcc75fd start (in libdyld.dylib)
    abort() called

    I too have this problem. Did you ever find a solution??

  • Error Adding object to collection

    Hi all... I'm using Toplink + ADF Faces...
    We have the following problem: There are 2 tables involved, table A and table B
    Table B has a FK to table A, therefore a one-to-one mapping from B to A and a one to many mapping (collection) from A to B.
    What I want to do is to add an object of type B to the collection of an A object. I'm showing an input form for the constructor of type B, a submit button, and a read only table bellow to show the items of the collection. I have done this several times and worked fine, now I have NO clue why this is not working.
    What I used to do to achieve this is to call the method of the type A "addB(B)" (to add the object) and then the "Execute" operation (to refresh the table shown) of the collection in which the addB method is adding objects.
    What I get is just:
    2006-11-17 13:53:30.421 WARNING JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null
    2006-11-17 13:53:30.421 WARNING java.lang.NullPointerException
    and no more details.... :-S
    Does anyone know why this could be happening???
    or
    Is there some other way of adding objects to a collection using ADF and toplink?? Any suggestion is more than welcome!! I've been trying for too long to solve this... :-(
    Thanks in advance

    Here is another symptom:
    a few days ago, I developed a search page of objects of type "C". This type, has a collection of objects of type "B". This page is working fine, now... I do exactly the same steps to create a new page with the same search functionallity, and I get the same NullPointerException described above (with no extra information).
    Since the development of that working page until now, I manually added the mapping of table "A", which was not mapped by the time we developed the working search page. So I guess something is wrong with this new mapping.
    Here are the steps i did to map the new table "A" and define the relationship with table B (through a foreing key defined in DB):
    - created Java objects from tables for table "A".
    - added a FK from "B"->"A" in table "B" in the Offline Database Sources (just like the FK in the real DB)
    - added a ValueHolder attribute to class "B" (with the appropiate get and set, and initializing it in the constructor of class "B")
    - added a List attribute in class "A" of objects of type "B" (with the appropiates add, remove, get and set methods), and initializing the List as a new ArrayList in the constructor.
    - in the toplink map, mapped the new attributes:
    one-to-one for the Valueholder in class "B" (using the appropiate FK)
    one-to-many for the List attributes in class "A" (using the appropiate FK)
    - refreshed all possible datacontrol
    And thats it... am I doing something wrong or missing something??
    Is there any other way to map a new table into an existing toplink mapping? I'm using Jdev 10.1.3 Integrated workbench...
    I will really appreciate any suggestion or comment, I really have no clue why this is happening.... Thanks in advance

  • Invalid table name  error when updating object in collection using SQL

    Hi,
    I have pl/sql code where I am selecting a object from a collection using sql select query. I am processing this record and now I want to update the collection with the new object. ie. ensure that the object that was fetched be removed and this new one be added.
    considering my_ot is the object type and my_tt is the table type.
    DECLARE
    my_col my_tt;
    my_col1 my_tt
    my_var my_ot;
    my_var2 VARCHAR2(10);
    BEGIN
    // populating my_col1 with select query
    //populating my_col with select query
    FOR my_col1.FIRST .. my_col.LAST LOOP
    //populating my_var2
    BEGIN
    SELECT my_ot(c.field1, c.field2 ,c.field3) INTO my_var FROM TABLE(my_col) c WHERE c.field3 = my_var2
    //processing the field my_VAR
    UPDATE TABLE(my_col) c SET c.field1 = my_var.field1 , c.field2 = my_var.field2 , WHERE c.field3 = my_var.field3;
    EXCEPTION WHEN NO_DATA_FOUND
    my_col.EXTEND;
    my_col(my_col.LAST) := // new my_ot object
    END;
    END LOOP;
    Here, when compiling the update query is not being compiled. I am getting a error 'invalid table name'. Is there any way to modify an object in the collection without knowing its index?
    If not, is it possible to find the index of a object in the collection in select query?
    Thanks in advance
    Paddy

    Hi,
    Is there any way to find the index of a object in the collection? Then I will simply replace the object at that index, right!
    Thanks
    Paddy

  • Should Parent objects be updated when adding a child?

    Hi,
    I have 2 objects in a one to many relationship, a parent with a collection
    of child objects.
    My parent object is being updated when I add child objects to it -
    although nothing on the parent object has changed (except maybe the
    JDOLOCKX column).
    Is this meant to happen - as part of the optimistic locking? Does it try
    and lock the owner of the collection when a new member is added?
    Thanks in advance,
    Chris

    We are planning a metadata extension to permit writing to a collection
    without changing optimistic lock values for the owning class.
    I don't have a good feel for the time frame of the feature yet.
    -Patrick
    On 5/21/02 1:06 PM, in article acduqj$e4j$[email protected], "Chris
    Kimpton" <[email protected]> wrote:
    Hi,
    This is occuring across JVMs for me - so I have put a crude re-try
    facility in place - it has a few goes at doing the work and then gives up
    if that is not sufficient. Not nice, but it seems to work.
    Chris
    David A. King wrote:
    I too have seen this behavior, which becomes frustrating when adding many
    children concurrently--I receive ConcurrentModificationExceptions on the
    parent, even though the parent itself did not change (except of course the
    collection of children) with optimisitic locking. I have had to serialize
    transactions manually to avoid the exceptions.
    Thanks,
    David A. King
    Chris Kimpton wrote:
    Hi,
    I have 2 objects in a one to many relationship, a parent with a collection
    of child objects.
    My parent object is being updated when I add child objects to it -
    although nothing on the parent object has changed (except maybe the
    JDOLOCKX column).
    Is this meant to happen - as part of the optimistic locking? Does it try
    and lock the owner of the collection when a new member is added?
    Thanks in advance,
    Chris

  • BUG - OJC 10.1.3.2 doesn't allow upcast when adding to generic Collection

    JDeveloper: 10.1.3.2.0.4066
    Compile Errors:
    method asList(Crusty, Slush, Powder) not found in class java.util.Arrays
    method addAll(java.util.List<Snow>, Light, Heavy) not found in class java.util.Collections
    When adding a group of elements to a Collection which uses generics, the ojc compiler does not allow upcasting, but the same upcasting is permitted by the javac compiler.
    The following code is taken from Bruce Eckel's Thinking In Java, 4th edition, page 396. It reproduces the compile problems:
    import java.util.*;
    class Snow {}
    class Powder extends Snow {}
    class Light extends Powder {}
    class Heavy extends Powder {}
    class Crusty extends Snow {}
    class Slush extends Snow {}
    public class AsListInference {
      public static void main(String[] args) {
        //Following line compiles under javac but not under ojc:
        List<Snow> snow1 = Arrays.asList(new Crusty(), new Slush(), new Powder());
        System.out.println("snow1:");
        for (Snow s : snow1) {
          System.out.println(s);
        //Following line doesn't compile under javac or ojc:
        //List<Snow> snow2 = Arrays.asList(new Light(), new Heavy());
        List<Snow> snow3 = new ArrayList<Snow>();
        //Following line compiles under javac but not under ojc:
        Collections.addAll(snow3, new Light(), new Heavy());
        System.out.println("snow3:");
        for (Snow s : snow3) {
          System.out.println(s);
        //Following line compiles under both javac and ojc:
        List<Snow> snow4 = Arrays.<Snow> asList(new Light(), new Heavy());
        System.out.println("snow4:");
        for (Snow s : snow4) {
          System.out.println(s);
    }

    Loren,
    thanks will file this too
    Frank

  • Application installation when adding an additional RD Session Host to a collection

    I am in the process of adding a second RD session host to a collection in my Windows Server 2012 R2 RDS deployment. When doing this should I install the applications I wish to publish as remoteapps before adding the host to the collection or after?
    There doesn't appear to be a way to add the RD session host role before adding the host to the collection.
    I am concerned that if I install the applications before adding to the collection, the server may not install them in 'change user /install' mode. However if I install them afterwards, users may be load balanced to the new RD Session host before the
    applications are installed.
    I was just wondering what procedures others use when adding additional RD session host servers to existing collections?
    Thanks

    Hi,
    First you install RD Session Host on the new server, then applications, then add it to collection.  You can install RDSH via Server Manager -- RDS -- Overview -- Deployment Servers -- Tasks -- Add RD Session Host Servers.
    -TP

  • Adding object to collection outside of unit of work?

    Hi,
    Tried to find the answer in this forum but difficult to know what keywords to use...anyway
    What I am trying to do is so simple I can only believe I am missing the point somewhat ;-)
    I have an object Licence that has a Set of LicenceHolders. I have a licence already saved in the db and the application now has cause to add a licenceHolder. I create the licenceHolder as a new object then get the licence out of the db, add the licenceHolder to the Set, then I make a call to my data persistance business class to make the save to the database. I.e. I have a separate layer to do the persistance from my business logic. The latter being the specific method to say 'add a licence holder to the licence', the former being 'save the licenceHolder, and update the link table between the licence and licenceHolder' (m - m relationship).
    The problem I have is that in my business method licence.addLicencee(licenceHolder) doesn't save my licenceHolder and link table if I don't include the bold line below. This does work but see below for more comments
    code snippet for business method....
    // lm is the persistance method that gets licence from db
    PremisesLicence licence = (PremisesLicence) lm.getLicence(premisesLicenceId);
    // licenceePerson - new object not yet persisted
    licence.addLicenceHolder(licenceePerson);     
    //lhm is another persistance method to save licenceePerson and update licence_licenceHolder link table
    lhm.addLicenceHolder(licenceePerson, licence);
    code for lhm...
    public void addLicenceHolder(ILicenceHolder licenceHolder, Licence licence) throws DataAccessException {
    UnitOfWork uow = aSession.acquireUnitOfWork();
    try {
         Licence licenceClone = (Licence) uow.readObject(licence);
    licenceClone.addLicenceHolder(licenceHolder);
         uow.registerNewObject(licenceHolder);
         uow.commit();
    } catch (Exception e) {
         e.printStackTrace();
         throw new DataAccessException(e);
    I don't believe I should have to do the bold line as it is business logic in the persistance logic. I have already (in business method) said 'this licence has this licenceHolder' why should I have to repeat it in the persistance layer too. This can only lead to bugs in my software - I need all the help I can not to introduce any more ;-)
    Comments please?
    Thanks
    Conrad

    We've been working with TopLink for a while now, and had some issues with what you are doing. The following way is how we interact with TopLink to enable modifications outside the UoW:
    - When returning objects from you DAO layer always return a copy of the retrieved objects (try Session.copyObject()), not the object returned by TopLink.
    - Do modifications to the copied objects
    - Pass the modified object graph to the DAO layer and use uow.mergeCloneWithReferences() to merge in differences
    - Save to database with TopLink
    From our experience, the reason you have to copy things is because what TopLink returns is the cached objects. So because you then will modify the cached objects, TopLink will not discover changes (comparing an object to itself will not give any differences). At least that was the only explanation we could find to our strange behaviour.
    This is not a very efficient way to do things, and I think that if you are able to have a UoW open during this whole process it would be much more efficient. For an easy way to do this with web applications check out the TopLink integration with Springframework.
    Please let me know if anyone has any feedback to this way of doing it. I know it's not ideal, but it is the best solution we found for detaching the objects.

  • TableSorter errors when adding new data

    so here is the deal:
    I am using the TableSorter.java helper class with DefaultTableModel
    from: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    It works great when the data is static and I get it for the first time. however, occationally, when adding new data I get a NullPointerException error.
    in use:
    DefaultTableModel.addRow()
    DefaultTableModel.removeRow() and
    DefaultTableModel.insertRow() methods.
    Error:
    java.lang.ArrayIndexOutOfBoundsException: 5
         at com.shared.model.TableSorter.modelIndex(TableSorter.java:294)
         at com.shared.model.TableSorter.getValueAt(TableSorter.java:340)
         at javax.swing.JTable.getValueAt(Unknown Source)
         at javax.swing.JTable.prepareRenderer(Unknown Source)...
    code problem I:
        public Object getValueAt(int row, int column)
            return tableModel.getValueAt(modelIndex(row), column);
        }code problem II:
        public int modelIndex(int viewIndex)
                 return getViewToModel()[viewIndex].modelIndex;     
        }TableSroter class:
    package com.shared.model;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.*;
    * TableSorter is a decorator for TableModels; adding sorting
    * functionality to a supplied TableModel. TableSorter does
    * not store or copy the data in its TableModel; instead it maintains
    * a map from the row indexes of the view to the row indexes of the
    * model. As requests are made of the sorter (like getValueAt(row, col))
    * they are passed to the underlying model after the row numbers
    * have been translated via the internal mapping array. This way,
    * the TableSorter appears to hold another copy of the table
    * with the rows in a different order.
    * <p/>
    * TableSorter registers itself as a listener to the underlying model,
    * just as the JTable itself would. Events recieved from the model
    * are examined, sometimes manipulated (typically widened), and then
    * passed on to the TableSorter's listeners (typically the JTable).
    * If a change to the model has invalidated the order of TableSorter's
    * rows, a note of this is made and the sorter will resort the
    * rows the next time a value is requested.
    * <p/>
    * When the tableHeader property is set, either by using the
    * setTableHeader() method or the two argument constructor, the
    * table header may be used as a complete UI for TableSorter.
    * The default renderer of the tableHeader is decorated with a renderer
    * that indicates the sorting status of each column. In addition,
    * a mouse listener is installed with the following behavior:
    * <ul>
    * <li>
    * Mouse-click: Clears the sorting status of all other columns
    * and advances the sorting status of that column through three
    * values: {NOT_SORTED, ASCENDING, DESCENDING} (then back to
    * NOT_SORTED again).
    * <li>
    * SHIFT-mouse-click: Clears the sorting status of all other columns
    * and cycles the sorting status of the column through the same
    * three values, in the opposite order: {NOT_SORTED, DESCENDING, ASCENDING}.
    * <li>
    * CONTROL-mouse-click and CONTROL-SHIFT-mouse-click: as above except
    * that the changes to the column do not cancel the statuses of columns
    * that are already sorting - giving a way to initiate a compound
    * sort.
    * </ul>
    * <p/>
    * This is a long overdue rewrite of a class of the same name that
    * first appeared in the swing table demos in 1997.
    * @author Philip Milne
    * @author Brendon McLean
    * @author Dan van Enckevort
    * @author Parwinder Sekhon
    * @version 2.0 02/27/04
    public class TableSorter extends AbstractTableModel
        protected TableModel tableModel;
        public static final int DESCENDING = -1;
        public static final int NOT_SORTED = 0;
        public static final int ASCENDING = 1;
        private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
        public static final Comparator COMPARABLE_COMAPRATOR = new Comparator()
            public int compare(Object o1, Object o2)
                return ((Comparable) o1).compareTo(o2);
        public static final Comparator LEXICAL_COMPARATOR = new Comparator()
            public int compare(Object o1, Object o2)
                return o1.toString().compareTo(o2.toString());
        private Row[] viewToModel;
        private int[] modelToView;
        private JTableHeader tableHeader;
        private MouseListener mouseListener;
        private TableModelListener tableModelListener;
        private Map columnComparators = new HashMap();
        private List sortingColumns = new ArrayList();
        public TableSorter()
            this.mouseListener = new MouseHandler();
            this.tableModelListener = new TableModelHandler();
        public TableSorter(TableModel tableModel)
            this();
            setTableModel(tableModel);
        public TableSorter(TableModel tableModel, JTableHeader tableHeader)
            this();
            setTableHeader(tableHeader);
            setTableModel(tableModel);
        private void clearSortingState()
            viewToModel = null;
            modelToView = null;
        public TableModel getTableModel()
            return tableModel;
        public void setTableModel(TableModel tableModel)
            if (this.tableModel != null)
                this.tableModel.removeTableModelListener(tableModelListener);
            this.tableModel = tableModel;
            if (this.tableModel != null)
                this.tableModel.addTableModelListener(tableModelListener);
            clearSortingState();
            fireTableStructureChanged();
        public JTableHeader getTableHeader()
            return tableHeader;
        public void setTableHeader(JTableHeader tableHeader)
            if (this.tableHeader != null)
                this.tableHeader.removeMouseListener(mouseListener);
                TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
                if (defaultRenderer instanceof SortableHeaderRenderer)
                    this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
            this.tableHeader = tableHeader;
            if (this.tableHeader != null)
                this.tableHeader.addMouseListener(mouseListener);
                this.tableHeader.setDefaultRenderer
                        new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer())
        public boolean isSorting()
            return sortingColumns.size() != 0;
        private Directive getDirective(int column)
            for (int i = 0; i < sortingColumns.size(); i++)
                Directive directive = (Directive)sortingColumns.get(i);
                if (directive.column == column)
                    return directive;
            return EMPTY_DIRECTIVE;
        public int getSortingStatus(int column)
            return getDirective(column).direction;
        private void sortingStatusChanged()
            clearSortingState();
            fireTableDataChanged();
            if (tableHeader != null)
                tableHeader.repaint();
        public void setSortingStatus(int column, int status)
            Directive directive = getDirective(column);
            if (directive != EMPTY_DIRECTIVE)
                sortingColumns.remove(directive);
            if (status != NOT_SORTED)
                sortingColumns.add(new Directive(column, status));
            sortingStatusChanged();
        protected Icon getHeaderRendererIcon(int column, int size)
            Directive directive = getDirective(column);
            if (directive == EMPTY_DIRECTIVE)
                return null;
            return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
        private void cancelSorting()
            sortingColumns.clear();
            sortingStatusChanged();
        public void setColumnComparator(Class type, Comparator comparator)
            if (comparator == null)
                columnComparators.remove(type);
            else
                columnComparators.put(type, comparator);
        protected Comparator getComparator(int column)
            Class columnType = tableModel.getColumnClass(column);
            Comparator comparator = (Comparator) columnComparators.get(columnType);
            if (comparator != null)
                return comparator;
            if (Comparable.class.isAssignableFrom(columnType))
                return COMPARABLE_COMAPRATOR;
            return LEXICAL_COMPARATOR;
        private Row[] getViewToModel()
            if (viewToModel == null)
                int tableModelRowCount = tableModel.getRowCount();
                viewToModel = new Row[tableModelRowCount];
                for (int row = 0; row < tableModelRowCount; row++)
                    viewToModel[row] = new Row(row);
                if (isSorting())
                    Arrays.sort(viewToModel);
            return viewToModel;
        public int modelIndex(int viewIndex)
                 return getViewToModel()[viewIndex].modelIndex;     
        private int[] getModelToView()
            if (modelToView == null)
                int n = getViewToModel().length;
                modelToView = new int[n];
                for (int i = 0; i < n; i++)
                    modelToView[modelIndex(i)] = i;
            return modelToView;
        // TableModel interface methods
        public int getRowCount()
            return (tableModel == null) ? 0 : tableModel.getRowCount();
        public int getColumnCount()
            return (tableModel == null) ? 0 : tableModel.getColumnCount();
        public String getColumnName(int column)
            return tableModel.getColumnName(column);
        public Class getColumnClass(int column)
            return tableModel.getColumnClass(column);
        public boolean isCellEditable(int row, int column)
            return tableModel.isCellEditable(modelIndex(row), column);
        public Object getValueAt(int row, int column)
            return tableModel.getValueAt(modelIndex(row), column);
        public void setValueAt(Object aValue, int row, int column)
            tableModel.setValueAt(aValue, modelIndex(row), column);
        // Helper classes
        private class Row implements Comparable
            private int modelIndex;
            public Row(int index)
                this.modelIndex = index;
            public int compareTo(Object o)
                int row1 = modelIndex;
                int row2 = ((Row) o).modelIndex;
                for (Iterator it = sortingColumns.iterator(); it.hasNext();)
                    Directive directive = (Directive) it.next();
                    int column = directive.column;
                    Object o1 = tableModel.getValueAt(row1, column);
                    Object o2 = tableModel.getValueAt(row2, column);
                    int comparison = 0;
                    // Define null less than everything, except null.
                    if (o1 == null && o2 == null)
                        comparison = 0;
                    } else if (o1 == null)
                        comparison = -1;
                    } else if (o2 == null)
                        comparison = 1;
                    } else {
                        comparison = getComparator(column).compare(o1, o2);
                    if (comparison != 0)
                        return directive.direction == DESCENDING ? -comparison : comparison;
                return 0;
        private class TableModelHandler implements TableModelListener
            public void tableChanged(TableModelEvent e)
                // If we're not sorting by anything, just pass the event along.            
                if (!isSorting())
                    clearSortingState();
                    fireTableChanged(e);
                    return;
                // If the table structure has changed, cancel the sorting; the            
                // sorting columns may have been either moved or deleted from            
                // the model.
                if (e.getFirstRow() == TableModelEvent.HEADER_ROW)
                    cancelSorting();
                    fireTableChanged(e);
                    return;
                // We can map a cell event through to the view without widening            
                // when the following conditions apply:
                // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
                // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
                // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
                // d) a reverse lookup will not trigger a sort (modelToView != null)
                // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
                // The last check, for (modelToView != null) is to see if modelToView
                // is already allocated. If we don't do this check; sorting can become
                // a performance bottleneck for applications where cells 
                // change rapidly in different parts of the table. If cells
                // change alternately in the sorting column and then outside of            
                // it this class can end up re-sorting on alternate cell updates -
                // which can be a performance problem for large tables. The last
                // clause avoids this problem.
                int column = e.getColumn();
                if (e.getFirstRow() == e.getLastRow()
                        && column != TableModelEvent.ALL_COLUMNS
                        && getSortingStatus(column) == NOT_SORTED
                        && modelToView != null)
                    int viewIndex = getModelToView()[e.getFirstRow()];
                    fireTableChanged(new TableModelEvent(TableSorter.this,
                                                         viewIndex, viewIndex,
                                                         column, e.getType()));
                    return;
                // Something has happened to the data that may have invalidated the row order.
                clearSortingState();
                fireTableDataChanged();
                return;
        private class MouseHandler extends MouseAdapter
            public void mouseClicked(MouseEvent e)
                JTableHeader h = (JTableHeader) e.getSource();
                TableColumnModel columnModel = h.getColumnModel();
                int viewColumn = columnModel.getColumnIndexAtX(e.getX());
                int column = columnModel.getColumn(viewColumn).getModelIndex();
                if (column != -1)
                    int status = getSortingStatus(column);
                    if (!e.isControlDown())
                        cancelSorting();
                    // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                    // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                    status = status + (e.isShiftDown() ? -1 : 1);
                    status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
                    setSortingStatus(column, status);
        private static class Arrow implements Icon
            private boolean descending;
            private int size;
            private int priority;
            public Arrow(boolean descending, int size, int priority)
                this.descending = descending;
                this.size = size;
                this.priority = priority;
            public void paintIcon(Component c, Graphics g, int x, int y)
                Color color = c == null ? Color.GRAY : c.getBackground();            
                // In a compound sort, make each succesive triangle 20%
                // smaller than the previous one.
                int dx = (int)(size/2*Math.pow(0.8, priority));
                int dy = descending ? dx : -dx;
                // Align icon (roughly) with font baseline.
                y = y + 5*size/6 + (descending ? -dy : 0);
                int shift = descending ? 1 : -1;
                g.translate(x, y);
                // Right diagonal.
                g.setColor(color.darker());
                g.drawLine(dx / 2, dy, 0, 0);
                g.drawLine(dx / 2, dy + shift, 0, shift);
                // Left diagonal.
                g.setColor(color.brighter());
                g.drawLine(dx / 2, dy, dx, 0);
                g.drawLine(dx / 2, dy + shift, dx, shift);
                // Horizontal line.
                if (descending) {
                    g.setColor(color.darker().darker());
                } else {
                    g.setColor(color.brighter().brighter());
                g.drawLine(dx, 0, 0, 0);
                g.setColor(color);
                g.translate(-x, -y);
            public int getIconWidth()
                return size;
            public int getIconHeight()
                return size;
        private class SortableHeaderRenderer implements TableCellRenderer
            private TableCellRenderer tableCellRenderer;
            public SortableHeaderRenderer(TableCellRenderer tableCellRenderer)
                this.tableCellRenderer = tableCellRenderer;
            public Component getTableCellRendererComponent(JTable table,
                                                           Object value,
                                                           boolean isSelected,
                                                           boolean hasFocus,
                                                           int row,
                                                           int column)
                Component c = tableCellRenderer.getTableCellRendererComponent(table,
                        value, isSelected, hasFocus, row, column);
                if (c instanceof JLabel) {
                    JLabel l = (JLabel) c;
                    l.setHorizontalTextPosition(JLabel.LEFT);
                    int modelColumn = table.convertColumnIndexToModel(column);
                    l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
                return c;
        private static class Directive
            private int column;
            private int direction;
            public Directive(int column, int direction)
                this.column = column;
                this.direction = direction;
    }any input will be appreciated.
    thanks
    Peter

    The code you posted doesn't help us at all. Its just a duplicate of the code from the tutorial. The custom code is what you have written. For example do you update the TableModel from the Event Thread? Do you update the SortModel or the DefaultTableModel? If you actually provide your test code and somebody has already downloaded the sort classes, then maybe they will test your code against the classes. But I doubt if people will download the sort classes and create a test program just to see if they can duplicate your results (at least I know I'm not about to).

  • Adding objects to a Map

    Hi all
    I have created a program that add objects to a Map
    Code below shows the method used when added
    public String add(int bookNumber, String title, String releaseYear, String author)
    Book book = new Book(bookNumber, title, releaseYear, author);
    if (library.containsKey(new Integer(book.getBookNumber())))
    return "Failure - Book is already in the Library";
    library.put(new Integer(book.getBookNumber()), book);
    return "Success Book Added";
    Trouble is when it adds the book(object) to the collection(map) it adds it anywhere in the map, eg I could have a book in place 1001 then the next book in place 1056, is there anyway I can get the method to add the object in order EG. There is a book in 1001 and when I add another object it goes to place 1002
    Any help would be great
    Thank all for your time
    James

    I don't know why you'd care about where in the Map a paticular object is but if you want it sorted you could try a TreeMap. And if you want unique keys then use a HashMap.

  • When will garbage will be collected ?

    hi,
    when will garbage will be collected if our class contains static methods and non static methods.
    when it will exactly happen
    thanks in advance.
    regards
    srinivas.

    That is what I am trying to figure out, when are there
    no more references to it based on what i have
    described? As I mentioned, the Thread is added to a ThreadGroup when it is created. In your case the thread can be cleaned up when the Threads has been removed from the ThreadGroup.
    I'm not really sure. Won't there need to be a new thread per request, If you can use one thread to send all the replies (which also need to be serialised) what is special about the requests that they need their own threads. How is the serialization of the requests so fundermentaly different?
    otherwise how will the thread get the object to be serialized,I don't see how the objects are serialized and how you use your threads are releated???
    or is a setRequest(someRequest) on the thread from the model OK to do.I would use another thread that the GUI thread to send requests and recieve replies.
    I was somewhat leery of calling a setter from the model on an already running thread. I would call the setter for the GUI thread.
    How you do this is:
    - Read reply using the thread reading replies.
    - Add a Runnable to the GUI Thread to set the values via SwingUtilities.invokeLater()

  • TableAdapter Configuration Wizard gives error when adding new TableAdapter

    Hi,
    I recently downloaded and installed the ODT for visual studio on my computer. I am running VS2008 on Windows 7 64-bit. I am able to create an ODP.NET connection to the Oracle XE 10.2g instance that is running on my computer with no problems and use that connection to browse the database. When I add a DataSet to my project, and start adding TableAdapters to the DataSet, I am getting errors. In an attempt to figure out what the problem is, I have followed various scenarios. I will describe each scenario, and what the end result is, and then after I have described them all, I will explain what I think the problem might be. Here are the different scenarios I have used:
    Scenario 1:
    From the Server Explorer, highlight ALL of the tables in my schema and drag them to the designer (all table adapters are added with no issues). I can add additional queries to each of the TableAdapters and then change the additional queries by right clicking and choosing "Configure". This all works with no issues. However, on certain TableAdapters, if I try to modify the primary query (Fill,GetData()), I can open the query editor just fine, change various settings, etc, but when I click on "Finish" I get the following error:
    Configure TableAdapter TABLENAME failed.
    Index was outside the bounds of the array.
    Scenario 2:
    From the Server Explorer, drag tables from my schema onto the designer one at a time. Some tables get added just fine, but for the rest of them, I get the following error:
    Failed to merge object(s).
    Index was outside the bounds of the array.
    Scenario 3:
    On the Dataset Designer, add tables one at a time by right clicking and choosing "Add -> TableAdapter" and then using SQL to define the query for each table. Some tables get added just fine, but for the rest of them, I get the following error:
    Failed to add TableAdapter.
    Index was outside the bounds of the array.
    Ok... now that I have described all of the different scenarios, I will explain what I think the problem is, and why. Based on my research, I believe the underlying problem has to do with Foreign Key Constraints on the various tables. While working on Scenarios 2 & 3, the same exact tables worked just fine in both scenarios. When I started looking at the definitions for the tables in my schema, it turns out that all of the tables that failed had foreign key constraints defined. When I remove the FK constraints from a table, I am then able to add it to my dataset and change the default query with no problems. My original application used the System.Data.OracleClient provided by Microsoft. When adding my tableadapters using the microsoft data provider, the FK relations are automatically generated for me in the designer, but not with the Oracle Data Provider
    I would be happy to provide you with the DDL that I used for creating my schema (it is not very big) if needed.
    Thanks,
    Jim

    Sorry let me clarify some of the config a little more.
    MAIL101 - Exch 2013
    MAIL102 - Exch 2013
    AP104 - Witness (strictly a witness nothing else on this machine)
    EDGE01 - Exch 2007 Edge
    CAS01 - Exch 2007 Hub/CAS load balancer for CAS02/03
    CAS02 - Exch 2007 Hub/CAS
    CAS03 - Exch 2007 Hub/CAS
    MBOX01 - Exch 2007 Mail cluster
    MBOX02 - Exch 2007 Mail cluster node
    MBOX03 - Exch 2007 Mail cluster node
    RDC01, RDC02, RDC03 - all 2008 R2 root domain controllers for rootdomain.rootdomain
    DC01, DC02, DC03, DC04 - all 2008 R2 domain controllers for us.rootdomain.rootdomain
    All DCs are Global Catalogs.
    I can ping all DCs and root DCs fromboth MAIL101 and 102
    The Exchange Replication service is running on both MAIL101 and 102.
    DC03 is in the same site as the MAIL101/102 servers so I'll run all replication tests from here.
    DCDIAG comes back with all tests passed.
    repadmin /replsum comes back with 0 fails and no errors largest delta for any intersite communication is 13min.
    When I run Test-ReplicationHealth -Identity MAIL101 and also 102 they both come back as everything passed.  No errors.

Maybe you are looking for

  • Photoshop Elements 10 Help with image jumping around the screen

    I'm using a trial version of Elements 10 that I'm interested in buying it but 50% of the time when I click on an image so that I can click and drag it around the screen, it jumps off the screen.  I have been using Elements 6 and never had this proble

  • Migrating groups and users from QA to Production

    Post Author: KSK CA Forum: Administration Hi, I have to migrate security setup with Groups and users from QA to Production box . setup is in Unix. Note: my production already have some other projects related groups and Unix.. and when I say migrate,

  • Template table error

    Hi Friends I'm creating workflow to pull data from SQL server to BW . I've created data flow from SQL table to template table then into BW transfer structure. When I validate the project it sayd no errors but when I execute the jon I get the followin

  • OCA and OCP Post-nominal letters

    Hi All, I recently passed OCA and OCP for Java 7.  I was wondering if there is an official industry accepted standard to place these qualifications after your name. I saw Bert Bates, co-author of the Java 7 study guide, placed: Bert Bates OCA OCP. Is

  • IPhone 4 ring on calendar reminder with earphones in...

    Hello! When I have my earphones plugged in the iCal-reminders on my iPhone 4 only ring in my earphones, and I only hear if I have the earphones in my ears... Do you know any setting that makes the iPhone ring (loud) so I hear even if I have the earph