#1339 - Regression: Fix for not throwing OptimisticLockException when loaded bean has @Version property set

This commit is contained in:
Rob Bygrave
2018-03-07 20:19:48 +13:00
parent 8711ebc6f7
commit e182190f96
2 changed files with 41 additions and 12 deletions
@@ -2,10 +2,12 @@ package org.tests.basic;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import org.tests.model.basic.EBasicVer;
import org.junit.Assert;
import org.junit.Test;
import org.tests.model.basic.EBasicVer;
import org.tests.model.basic.UTMaster;
import javax.persistence.OptimisticLockException;
import java.sql.Timestamp;
public class TestIUDVanilla extends BaseTestCase {
@@ -66,4 +68,15 @@ public class TestIUDVanilla extends BaseTestCase {
Ebean.update(e3);
}
@Test(expected = OptimisticLockException.class)
public void modifyVersion_expect_optimisticLock() {
UTMaster e0 = new UTMaster("save me");
Ebean.save(e0);
// for this case we know 42 should throw OptimisticLockException
e0.setVersion(42);
Ebean.update(e0);
}
}