mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-13 06:42:57 +00:00
Update tests only - TestJacksonPlainBean with dirtyDetection = false property
This commit is contained in:
1 parent
c66d248e96
commit
5aa8557168
2 files changed
+25
-12
No files matched your search
@@ -17,6 +17,9 @@ public class EBasicPlain {
|
|||||||
@DbJson(length = 500)
|
@DbJson(length = 500)
|
||||||
PlainBean plainBean;
|
PlainBean plainBean;
|
||||||
|
|
||||||
|
@DbJson(length = 500, dirtyDetection = false)
|
||||||
|
PlainBean plainBean2;
|
||||||
|
|
||||||
@Version
|
@Version
|
||||||
long version;
|
long version;
|
||||||
|
|
||||||
@@ -44,6 +47,14 @@ public class EBasicPlain {
|
|||||||
this.plainBean = plainBean;
|
this.plainBean = plainBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlainBean getPlainBean2() {
|
||||||
|
return plainBean2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlainBean2(PlainBean plainBean2) {
|
||||||
|
this.plainBean2 = plainBean2;
|
||||||
|
}
|
||||||
|
|
||||||
public long getVersion() {
|
public long getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,25 +16,20 @@ public class TestJacksonPlainBean {
|
|||||||
DB.getDefault();
|
DB.getDefault();
|
||||||
LoggedSqlCollector.start();
|
LoggedSqlCollector.start();
|
||||||
|
|
||||||
PlainBean content = new PlainBean();
|
PlainBean content = new PlainBean("foo", 42);
|
||||||
content.setAlong(42);
|
|
||||||
content.setName("foo");
|
|
||||||
|
|
||||||
EBasicPlain bean = new EBasicPlain();
|
EBasicPlain bean = new EBasicPlain();
|
||||||
bean.setAttr("attr0");
|
bean.setAttr("attr0");
|
||||||
bean.setPlainBean(content);
|
bean.setPlainBean(content);
|
||||||
|
bean.setPlainBean2(new PlainBean("bar", 27));
|
||||||
|
|
||||||
DB.save(bean);
|
DB.save(bean);
|
||||||
expectedSql(0, "insert into ebasic_plain (attr, plain_bean, version) values (?,?,?)");
|
expectedSql(0, "insert into ebasic_plain (attr, plain_bean, plain_bean2, version) values (?,?,?,?)");
|
||||||
|
|
||||||
|
|
||||||
// inserted plainBean has not been mutated
|
// inserted plainBean has not been mutated
|
||||||
bean.setAttr("attr1");
|
bean.setAttr("attr1");
|
||||||
DB.save(bean);
|
DB.save(bean);
|
||||||
expectedSql(0, "update ebasic_plain set attr=?, version=? where id=? and version=?");
|
expectedSql(0, "update ebasic_plain set attr=?, version=? where id=? and version=?");
|
||||||
|
|
||||||
|
|
||||||
// inserted plainBean has now been mutated
|
// inserted plainBean has now been mutated
|
||||||
content.setName("notFoo");
|
content.setName("notFoo");
|
||||||
bean.setAttr("attr2");
|
bean.setAttr("attr2");
|
||||||
@@ -50,17 +45,24 @@ public class TestJacksonPlainBean {
|
|||||||
DB.save(found);
|
DB.save(found);
|
||||||
expectedSql(1, "update ebasic_plain set plain_bean=?, version=? where id=? and version=?");
|
expectedSql(1, "update ebasic_plain set plain_bean=?, version=? where id=? and version=?");
|
||||||
|
|
||||||
|
// dirtyDetection = false, so not included in update
|
||||||
// update bean, mutate PlainBean only
|
found.getPlainBean2().setName("Modification Ignored");
|
||||||
|
// dirtyDetection = true, mutation detected
|
||||||
plainBean.setName("mod2");
|
plainBean.setName("mod2");
|
||||||
DB.save(found);
|
DB.save(found);
|
||||||
expectedSql(0, "update ebasic_plain set plain_bean=?, version=? where id=? and version=?");
|
expectedSql(0, "update ebasic_plain set plain_bean=?, version=? where id=? and version=?");
|
||||||
|
|
||||||
|
|
||||||
// update bean, not mutating PlainBean
|
// update bean, not mutating PlainBean
|
||||||
found.setAttr("attr3");
|
found.setAttr("attr3");
|
||||||
DB.save(found);
|
DB.save(found);
|
||||||
expectedSql(LoggedSqlCollector.stop(), 0, "update ebasic_plain set attr=?, version=? where id=? and version=?");
|
expectedSql(0, "update ebasic_plain set attr=?, version=? where id=? and version=?");
|
||||||
|
|
||||||
|
// dirtyDetection = false, set a new plainBean2 instance, included in update
|
||||||
|
found.setPlainBean2(new PlainBean("bar", 27));
|
||||||
|
DB.save(found);
|
||||||
|
expectedSql( 0, "update ebasic_plain set plain_bean2=?, version=? where id=? and version=?");
|
||||||
|
|
||||||
|
LoggedSqlCollector.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void expectedSql(int i, String s) {
|
private void expectedSql(int i, String s) {
|
||||||
|
|||||||
Reference in new issue
Block a user