permaculture playing cards*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes update method not throws DuplicateKeyException! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "update method not throws DuplicateKeyException!" Watch "update method not throws DuplicateKeyException!" New topic
Author

update method not throws DuplicateKeyException!

Strong Z.Q. Jiang
Greenhorn

Joined: Dec 25, 2005
Posts: 3
in my instruction:
// Modifies the fields of a record. The new value for field n
// appears in data[n]. Throws SecurityException
// if the record is locked with a cookie other than lockCookie.
public void update(int recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException;

why not throws DuplicateKeyException while create method throws DuplicateKeyException ? how to deal with update method's DuplicateKeyException?
Dhanasekar Dhakshin
Greenhorn

Joined: Jan 19, 2006
Posts: 5
Im also confused . . . .
Gary Hellman
Greenhorn

Joined: Sep 24, 2005
Posts: 11
One way - assume that one or more "fields" of your records make up a "key". An update would then not change the key, but just the other "fields" in that record.
If you need to change the key - then that would be a create (or first delete, then create).


Thanks<br />Gary<br />SCJP 1.4
Alex Sharkoff
Ranch Hand

Joined: Apr 11, 2004
Posts: 209
Hi,

I made my update method throw IllegalStateException with the DuplicateKeyException as a cause (ie IllegalStateException#getCause() returns DuplicateKeyException) should the given record be a duplicate of another one.



Alex (SCJP 1.4, SCBCD 1.3, SCWCD 1.4, SCJD 1.4)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: update method not throws DuplicateKeyException!
 
Similar Threads
Implement Data Access Layer
How to comprehend such a method in URLyBired?
Who to treate lockCookie in URLyBird?
Lock question!
URLyBird - Data.java