#1471 - Change stateless update on bean with no @Version property that updates 0 rows to throw EntityNotFoundException

This commit is contained in:
rob bygrave
2018-08-14 14:23:28 +12:00
parent 95dab97b1b
commit 80975acfbf
3 changed files with 29 additions and 7 deletions
@@ -11,6 +11,7 @@ import org.tests.model.basic.EBasic.Status;
import org.junit.Assert;
import org.junit.Test;
import javax.persistence.EntityNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
@@ -70,6 +71,28 @@ public class TestStatelessUpdate extends TransactionalTestCase {
}
@Test(expected = EntityNotFoundException.class)
public void update_NoRowsUpdated_expect_EntityNotFoundException() {
EBasic basic = new EBasic();
basic.setId(999999999);
basic.setName("something");
basic.setStatus(Status.ACTIVE);
Ebean.update(basic);
}
@Test
public void delete_NoRowsDeleted_expect_false() {
EBasic basic = new EBasic();
basic.setId(999999999);
basic.setName("something");
basic.setStatus(Status.ACTIVE);
assertThat(Ebean.delete(basic)).isFalse();
}
/**
* I am expecting that Ebean detects there aren't any changes and don't execute any query.
* Currently a {@link javax.persistence.PersistenceException} with message 'Invalid value "null" for parameter "SQL"' is thrown.