Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Seeking clarifications on Search and update functionality?

 
Vrinda Werdel
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have some doubts about the Search and update functionality. I would appreciate your thoughts on that.

1. Do an initial read get all the records.
This queries only non-deleted records. Becuase of this when I present the data to the user, the record
positions in the list are not the same as the one in DB. So when I update a record (Say position 10 ion GUI),
the position of the redord might be referring to a record in DB that is deleted. How can this be handled elegantly?

2. Search & update.

Simlilar problem happens when I do a search and update.

Ex. I query for 'Xanadu'. This may be the 20th record in DB. As the query resulted in 2 records,
the postion of the record is now 0(zero) which efeectively means the 1st record in DB?

How can I maintain the correlation between the old and new possitions of the DB records without incurring too much of an
overhead. and still maintain data consistency?

Thanks

Vrinda
 
Vrinda Werdel
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I hope I Was able to communicate my point clearly. Appreciate your inputs.

thanks

Vrinda
 
Jonas Isberg
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vrinda Werdel:
I hope I Was able to communicate my point clearly.

Considering you've got none replies so far, it seems like you didn't communicate clearly.

Maybe the lack of response is due to that it sounds like you want us to solve your problem. Perhaps you will get more feedback if you both tell us about your problem and your thoughts about how to solve it.

How do you consider to solve the problem?
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vrinda,

If I am understanding you correctly, you are wondering how to relate a record in your table to the underlying data file. Before you do a search it is easy... the record at position 0 in your table model is record #1 in the data file, position 1 is record #2, position 2 is record #3, and so on. However, after you preform a search, it is no longer so easy, because the record at position 0 may be record#5, position 1 may be record #8, position 2 may be record #21...

There are two ways I know of doing this. One involves storing the record number of each record somewhere in your table model (It doesn't have to be displayed in the table). This takes less overhead, but is slightly more complex...

The other takes advantage of primary keys if you implemented it. This is easier, but takes slightly more overhead (up to O(n), depending on how you implement it).

Hope this gets you pointed in the right direction.
[ March 25, 2005: Message edited by: Paul Bourdeaux ]
 
Vrinda Werdel
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul. I was thinking about the first option and trying to find out how we can hide columns in a JTable.

regards

Vrinda
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you create a custom data model, you can control what is returned. Here is a hint in the right direction, if you want to hind a column of data (i.e. the record number), you have to do a little more work in the getColumnCount() and getValueAt(int row, int column) methods...
 
Vrinda Werdel
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul.

Vrinda
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic