(Hackily) handle duplicate key exceptions.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1919 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2006-09-20 00:34:50 +00:00
parent a95babcc00
commit 4fb11519a8
@@ -29,6 +29,7 @@ import java.util.HashMap;
import com.samskivert.io.PersistenceException;
import com.samskivert.jdbc.ConnectionProvider;
import com.samskivert.jdbc.DuplicateKeyException;
/**
* Provides a base for classes that provide access to persistent objects. Also
@@ -442,7 +443,14 @@ public class DepotRepository
return modifier.invoke(conn);
} catch (SQLException sqe) {
throw new PersistenceException("Modifier failure " + modifier, sqe);
// convert this exception to a DuplicateKeyException if appropriate
String msg = sqe.getMessage();
if (msg != null && msg.indexOf("Duplicate entry") != -1) {
throw new DuplicateKeyException(msg);
} else {
throw new PersistenceException(
"Modifier failure " + modifier, sqe);
}
} finally {
_conprov.releaseConnection(getIdent(), false, conn);