mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Use MutationDetection replacing dirtyDetection and keepSource
Also adds NoMutationDetection to support NONE
This commit is contained in:
@@ -7,12 +7,9 @@ import io.ebean.annotation.DbJsonType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static io.ebean.annotation.MutationDetection.SOURCE;
|
||||
|
||||
@Entity
|
||||
public class EBasicJsonList {
|
||||
@@ -31,7 +28,7 @@ public class EBasicJsonList {
|
||||
@DbJson(length = 700)
|
||||
Map<String, PlainBean> beanMap = new LinkedHashMap<>();
|
||||
|
||||
@DbJson(length = 500, keepSource = true) // such that we can rebuild old values
|
||||
@DbJson(length = 500, mutationDetection = SOURCE) // such that we can rebuild old values
|
||||
PlainBean plainBean;
|
||||
|
||||
@DbJson(length = 50)
|
||||
|
||||
@@ -6,6 +6,8 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
|
||||
import static io.ebean.annotation.MutationDetection.NONE;
|
||||
|
||||
@Entity
|
||||
public class EBasicPlain {
|
||||
|
||||
@@ -17,7 +19,7 @@ public class EBasicPlain {
|
||||
@DbJson(length = 500)
|
||||
PlainBean plainBean;
|
||||
|
||||
@DbJson(length = 500, dirtyDetection = false)
|
||||
@DbJson(length = 500, mutationDetection = NONE) // only update when property set
|
||||
PlainBean plainBean2;
|
||||
|
||||
@Version
|
||||
|
||||
@@ -60,7 +60,7 @@ public class TestJacksonPlainBean {
|
||||
// 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=?");
|
||||
expectedSql(0, "update ebasic_plain set plain_bean2=?, version=? where id=? and version=?");
|
||||
|
||||
LoggedSqlCollector.stop();
|
||||
}
|
||||
@@ -69,7 +69,4 @@ public class TestJacksonPlainBean {
|
||||
assertThat(LoggedSqlCollector.current().get(i)).contains(s);
|
||||
}
|
||||
|
||||
private void expectedSql(List<String> sql, int i, String s) {
|
||||
assertThat(sql.get(i)).contains(s);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user