mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1626 - ENH: Add SqlUpdate.setParams(Object ... ) and SqlQuery.setParams(Object ... ) ... as convenient alternative to many setParameter() calls
This commit is contained in:
@@ -9,10 +9,28 @@ import org.junit.Test;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestSqlUpdateExceptions extends BaseTestCase {
|
||||
|
||||
private String sql = "insert into uuone (id, name, version) values (?,?,?)";
|
||||
|
||||
@Test
|
||||
public void simpleInsert() {
|
||||
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
Ebean.createSqlUpdate(sql)
|
||||
.setParams(id, "hi", 1)
|
||||
.executeNow();
|
||||
|
||||
UUID foundId = Ebean.createSqlQuery("select id from uuone where id = ?")
|
||||
.setParams(id)
|
||||
.findSingleAttribute(UUID.class);
|
||||
|
||||
assertThat(foundId).isEqualTo(id);
|
||||
}
|
||||
|
||||
@Test(expected = DuplicateKeyException.class)
|
||||
public void duplicateKey() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user