my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes delete record, update gui Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "delete record, update gui" Watch "delete record, update gui" New topic
Author

delete record, update gui

Ernst Steenbrink
Greenhorn

Joined: Oct 09, 2006
Posts: 3
I was wondering how to solve the following problem:
When a client reads the data, it is in a certain order. When one is deleted through the interface that we have to implement(contractor assignement). The order is disturbed. If the client than books a record by referencing it by an integer, the changes are that the wrong record is booked.
Do I need to solve this?
mmg
Greenhorn

Joined: May 10, 2006
Posts: 11
Of course you need to solve this

I don't know which assignment you have, but deleting a record shouldn't change the order of the other records. You just set the "deleted" flag, but the record numbers remain. This means there can been "gaps" in the record numbers and your application should be able to handle this.

Mathias
[ October 09, 2006: Message edited by: Mathias De Groof ]
Ernst Steenbrink
Greenhorn

Joined: Oct 09, 2006
Posts: 3
Hi Mathias,

The assignement I have is with the B&S database(broker of contractors).
The Gap you mention is not the problem. It is the dynamic behavior that is my problem. When a client has a list of records that it is displaying and in the server, 1 record is deleted and the client wants to update a record, it will not update the correct record.
Example:
Existing :
0 record0
1 record1
2 record2
3 record3
4 record4

now this is send to the client.
then record2 is deleted in the database :
0 record0
1 record1
X record2 -> deleted
2 record3
3 record4
Now the client wants record3 to be updated. so it calls update(3,data);
but in the server id 3 no points to record 4.
I believe this problem exists because the records are not used with a unique key but based on their sequential number.
2 solutions I see are:
1) have an update function to notify the clients that the data has changed.
2) Keep record of the last list of data that a client has gotten with a find and read.
So the question is, do I need to go this far?
mmg
Greenhorn

Joined: May 10, 2006
Posts: 11
I don't think you should shift record numbers the way you do.

If your initial situation is (where "N" is the deleted flag):

0 record0 N
1 record1 N
2 record2 N
3 record3 N
4 record4 N

After you delete record 2, this should be:

0 record0 N
1 record1 N
2 record2 Y
3 record3 N
4 record4 N

When a new record is inserted, you can just overwrite the deleted record2, and the inserted record becomes the new record2. This way you don't have any "shifting".

Off course I don't know if you can use this solution with your assignment (I have the URLyBird one myself), since you will have to keep a "deleted" flag in your DB.
Ernst Steenbrink
Greenhorn

Joined: Oct 09, 2006
Posts: 3
I think I see where I'am going wrong. In the client I have the following to get the data( in pseudo code):
while not exception:
read record

where I need to keep a list of non-deleted records in sequence without gaps.

I think I will have to replace this with an empty find to get a list of record numbers which don't have to be in sequence but can have gaps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: delete record, update gui
 
Similar Threads
Logical consistency of search results
myThread.isAlive() v.s. WeakReference ? URLyBird 1.2.2 using Socket
About the dead lock
"Serving" Remote Objects
lock() > delete() > unlock() > BANG!