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)
Support for sqlUpdate.executeBatch()
This commit is contained in:
@@ -69,4 +69,27 @@ public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
transaction.commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = DuplicateKeyException.class)
|
||||
public void duplicateKey_executeBatch() {
|
||||
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
try (Transaction transaction = Ebean.beginTransaction()) {
|
||||
|
||||
SqlUpdate sqlUpdate = Ebean.createSqlUpdate(sql);
|
||||
sqlUpdate.setParameter(1, id);
|
||||
sqlUpdate.setParameter(2, "hi in batch");
|
||||
sqlUpdate.setParameter(3, 1);
|
||||
sqlUpdate.addBatch();
|
||||
|
||||
sqlUpdate.setParameter(1, id);
|
||||
sqlUpdate.setParameter(2, "fail in batch");
|
||||
sqlUpdate.setParameter(3, 1);
|
||||
sqlUpdate.addBatch();
|
||||
int[] ints = sqlUpdate.executeBatch();
|
||||
|
||||
transaction.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user