This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Modify method in Data Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Modify method in Data Class" Watch "Modify method in Data Class" New topic
Author

Modify method in Data Class

Mathew Sam
Ranch Hand

Joined: Dec 19, 2001
Posts: 124
DataInfo test = find((newData.getValues())[0]);
if ((test != null) &&
(test.getRecordNumber()!=newData.getRecordNumber()))
{
throw new DatabaseException("Attempt to create a "+
"duplicate key by modification");
}
Above is a code snippet from modify method of Data class.Do you think when a record is updated is this check required ?.Duplicate key check is only reqired when a new record is added. Is it not.
HenkGijsbert
Greenhorn

Joined: Jan 07, 2002
Posts: 28
Some naughty client might try to modify the key field of a record to the value of an already existing key. So it is necessary.
Mathew Sam
Ranch Hand

Joined: Dec 19, 2001
Posts: 124
The find method is finding a record which has the same record number.Then again checking whether both the records are having same record number.I am not understanding the logic ? Am i missing some thing?
HenkGijsbert
Greenhorn

Joined: Jan 07, 2002
Posts: 28
The find method is NOT finding a method with the same record number, but with the same key value, wich is in the first field of a record:
newData.getValues()[0]. Please study the DataInfo class and the Data class to learn the difference between record number and key value.
Henk
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Modify method in Data Class
 
Similar Threads
B&S: Primary Key Considerations??
nx: All of URLy Bird 1.1.3 read/write lock(2)
question on the Data class
How column can be hidden in JTable without removing from model ?
NX: Home contractor assignment, update()/create(), DuplicateKeyException