Bill Hayes

Greenhorn
+ Follow
since Sep 24, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Bill Hayes

I've been working on this for about a month and a half with no luck. I am able to add a record to the table as I can go in through a query tool and see the new record. It doesn't appear in my JTable unless I leave the current master record then select that record again. There must be something simple I'm missing.
I think I figured out how to add the record to the child table. At least it seems to work when I query the database from a different tool. Now my problem is that I can't get the child table to refresh. I need to be able to refresh the child table (to see the new record) and also maintain the selections in the master table and also two other child tables.
Not sure if this belongs here or in Object Relational Mapping.
I'm working with the gui tools in netbeans to create a java persistence project.
I have two entities, A and B which have a one to many relationship, A being the owner. I have all the relationship stuff taken care of and it works so far.
I have Jframe with a master table, displaying records from A. The table is bound to a list which gets its results from a persistence query from an entity manager. Then I have a detail table which is bound through the master table's selected element and displays the records from the child table, B.
Now I want to add a record to the child table, B. I understand how to do this on the master table, essentially adding a row to the list that the table is bound to. But my detail table is not bound to a list. Can anyone help me understand how to add a record to the child table?
Thanks.
First off, I'm working in Netbeans on a Swing application using Toplink and binding.
I have all my entities set up and am able to bind to them using various components including text fields and tables. I am performing the binding by using the Netbeans GUI tools.
I have a JTable, jtable1 that is bound to one of my database tables. I have a second JTable, jtable2 that is bound to jtable1 selectedElements. I want to take the data from jtable2 and put it into a collection so I can sort and perform some calculations. Do I need to iterate over the selected rows or is there an easy way of returning jtable2 data as a collection?
I am relatively new to this but have been able to successfully accomplish what you're talking about with my own tables in the past couple of weeks.

In your products class you need something like this...


In your ProductsDescription class you need something like this...


Again, please keep in mind that this is new to me also. What I've done here seems to work, but I can't guarantee that it is 100% correct, is not missing something or does not include something extra. Therefore I hope that someone who has more knowledge can take a look and correct as necessary.
I am relatively new to this but have been able to successfully accomplish what you're talking about with my own tables.

In your products class you need this...
I have a custom table model which extends AbstractTableModel. It is populated with a RowSet. I can't figure out how to write a method to add a column to my custom table model. I understand that when using the DefaultTableModel I can write something like...


Ultimately, what I want to add is a new column as a check box. The user will be able to select any or all rows in the table. The selections will be used to filter a second table.
[ November 13, 2008: Message edited by: Bill Hayes ]
16 years ago
I would like to thank everyone for helping me work through this solution. In the end I used the HashMap and it works beautifully. My small file ended up being 1.3 million records and my large file ended up remaining around 3 million. I was able to load the 1.3m records into the HashMap with values stored as a List. I was then able to look up all 3m records in the HashTable and find my partial match on the third field. I had to sort out a Heap Space (out of memory) issue, but in the end I was able to do this all in less than 1 minute with the last run being 49 seconds. Quite an improvement over my initial solution taking 3 hours for only 17k records in the small file.
Thanks again,
Bill
16 years ago
Thanks for the clarification. I just want to make sure I'm understanding correctly.
Before I add my current key, I need to search the map to see if the key already exists. If it does exist I need to grab the exisitng value and add it to a List containing my current value then add the List to the map.

So when searching the map for an existing key, and the key is found, I first need to determine if the value is a single value or a List and handle appropriately? Or do I add every value as a List even if there ends up being only one value? The latter sounds easier to me, but is there a performace hit in doing so? My List will contain 5 fields per row.
16 years ago
It looks like HashMap allows the insertion of duplicate keys. And it seems that upon retrieval, if there are duplicate entries it grabs the first occurence. It is quite likely that I have duplicate keys. The correct entry will be evaluated upon retrieval of the value. Is there a way to handle multiple matches? I have no other way to make the key unique.
16 years ago
I just read up on HashMap. While this will prove useful for other things I'm working on, I'm not sure it will work in this case. I said I was matching on three fields but that's not 100% true. I'm matching on two fields and the third field is a partial match. The third value from the large file must be contained within the third field on the smaller file.
16 years ago
I've never used HashMap and am not familiar with it. I will have to do some more reading. Based on your explanation it does sound a lot more efficient than iterating over the entire ArrayList.
Thank you for the suggestion.
16 years ago
I have two csv text files, one with about 17,000 rows and the other with about 3,000,000 rows. The file with 3,000,000 has a field that I need to attach to each of the 17,000 rows if they match on three values.
My current setup is:
Read the 17,000 rows into an ArrayList using the Ostermiller CSVParser.
Read the 3,000,000 rows in using the Ostermiller CSVParser.
For each of the 3,000,000 rows iterate through the ArrayList and look for a match.
If a match is found write it out to a text file and exit the loop.
This solution works and I am able to process roughly 200 to 210 rows per second using the full file of 17,000 and a sample of about 75,000 from the large file.
My question is, is this a good solution or is there a better more efficient way of doing this? If my calculations are correct, it will take close to 3 hours to process the full file. And I may have to process the file several times.
16 years ago
I know it's possible to add a checkbox to a jtable by writing the code. Is there a way to accomplish this in Netbeans 6.1 using the GUI tools?
Well, I went back and created the separate methods as Craig Wood originally proposed. I was able to use getIFrame, getNextFrame and getTextField. I modified getTextField to getTable as I'm pulling the users selection from a JTable. This works great and returns the users selection.
The code for my button is clean and the separate methods keep things neat and organized.
Thank you.

16 years ago