mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1507 - SqlUpdate.execute PersistenceException is not translated into more specific exception (like DuplicateKeyException)
This commit is contained in:
@@ -8,6 +8,9 @@ import io.ebeaninternal.server.persist.BatchPostExecute;
|
||||
import io.ebeaninternal.server.persist.BatchedSqlException;
|
||||
import io.ebeaninternal.server.persist.PersistExecute;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Wraps all the objects used to persist a bean.
|
||||
*/
|
||||
@@ -95,6 +98,13 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
|
||||
return transaction.isBatchThisRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the SQLException into a specific exception given the platform.
|
||||
*/
|
||||
public PersistenceException translateSqlException(SQLException e) {
|
||||
return transaction.translate(e.getMessage(), e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the statement.
|
||||
*/
|
||||
|
||||
@@ -55,8 +55,8 @@ class ExeUpdateSql {
|
||||
request.postExecute();
|
||||
return rowCount;
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new PersistenceException(ex);
|
||||
} catch (SQLException e) {
|
||||
throw request.translateSqlException(e);
|
||||
|
||||
} finally {
|
||||
if (!batchThisRequest) {
|
||||
|
||||
Reference in New Issue
Block a user