Hi everyone.
DBMain.update() method does not throw a duplicate key exception, so correct me if I am wrong, the assumption was to not update the primary keys fields inside this method, and the person who wants to update a record primary key fields, he has to delete the record then reinsert it again.
This means I have to handle duplication for keys inside the update method in one of the following scenarios:
1- Ignore primary key fields came in passed array fields and update the other fields.
2- Read the record data again inside update method, check if primary key fields passed are not changed, if is, throw an
IllegalStateException to indicate the caller he can not update a record key, then update the records data accordingly in case the primary keys are not changed.
Of course extra JavaDoc will be added to update method to explain the expected scenario.
Please advice, which is the best way to handle it.
I am appreciate your fast response because I am planing to upload my assignment within few days