wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes when to throw DuplicateKeyException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "when to throw DuplicateKeyException" Watch "when to throw DuplicateKeyException" New topic
Author

when to throw DuplicateKeyException

fei lin
Ranch Hand

Joined: Nov 25, 2007
Posts: 39
in my create() of the interface, it throws DuplicateKeyException.
When should this be throw?
Vinicius Florentino
Greenhorn

Joined: Feb 26, 2008
Posts: 16
Depends. In my code: never.
=]
Gilles Marceau
Ranch Hand

Joined: Feb 17, 2007
Posts: 78
It depends the meaning you give to the record key.

One option is to consider the record key to be the record number. The
DuplicateKeyException is never thrown in that case (record numbers are all
differents).

Another option is to consider a subset of the record data as the key. For
example, contractor name + contractor location. But in that case, the update
method should throw the same exception.

This is really a matter of design choice.

Gilles
[ March 05, 2008: Message edited by: Gilles Marceau ]

SCJP 1.5<br />SCJD 1.6<br />SCBCD in progress...
 
Don't get me started about those stupid light bulbs.
 
subject: when to throw DuplicateKeyException
 
Similar Threads
NX: Home contractor assignment, update()/create(), DuplicateKeyException
NX: DuplicateKeyException
DuplicateKeyException
UrlyBird: When will the create() method throw DuplicateKeyException ?
Primary key and update method strange issue