Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

when to throw DuplicateKeyException

 
fei lin
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my create() of the interface, it throws DuplicateKeyException.
When should this be throw?
 
Vinicius Florentino
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends. In my code: never.
=]
 
Gilles Marceau
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic