diff --git a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
index bc3ae587f..476007ebe 100644
--- a/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
+++ b/ebean-api/src/main/java/io/ebean/config/DatabaseConfig.java
@@ -193,12 +193,6 @@ public class DatabaseConfig {
*/
private JsonConfig.Include jsonInclude = JsonConfig.Include.ALL;
- /**
- * When true then by default DbJson beans are assumed to be dirty.
- * I believe we want to change this default to false in the future.
- */
- private boolean jsonDirtyByDefault = true;
-
/**
* The database platform name. Used to imply a DatabasePlatform to use.
*/
@@ -743,26 +737,6 @@ public class DatabaseConfig {
this.jsonInclude = jsonInclude;
}
- /**
- * Return true if DbJson beans are assumed dirty by default.
- *
- * That is, when true beans that do not implement ModifyAwareType are by
- * default assumed to be dirty and included in updates.
- */
- public boolean isJsonDirtyByDefault() {
- return jsonDirtyByDefault;
- }
-
- /**
- * Set to false if we want DbJson beans to not be assumed to be dirty.
- *
- * That is, when true beans that do not implement ModifyAwareType are by
- * default assumed to be dirty and included in updates.
- */
- public void setJsonDirtyByDefault(boolean jsonDirtyByDefault) {
- this.jsonDirtyByDefault = jsonDirtyByDefault;
- }
-
/**
* Return the name of the Database.
*/
@@ -2935,7 +2909,6 @@ public class DatabaseConfig {
jsonInclude = p.getEnum(JsonConfig.Include.class, "jsonInclude", jsonInclude);
jsonDateTime = p.getEnum(JsonConfig.DateTime.class, "jsonDateTime", jsonDateTime);
jsonDate = p.getEnum(JsonConfig.Date.class, "jsonDate", jsonDate);
- jsonDirtyByDefault = p.getBoolean("jsonDirtyByDefault", jsonDirtyByDefault);
runMigration = p.getBoolean("migration.run", runMigration);
ddlGenerate = p.getBoolean("ddl.generate", ddlGenerate);
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java
index 28999e838..8ffb15372 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java
@@ -134,7 +134,7 @@ public final class DefaultTypeManager implements TypeManager {
this.postgres = isPostgres(config.getDatabasePlatform());
this.objectMapperPresent = config.getClassLoadConfig().isJacksonObjectMapperPresent();
this.objectMapper = (objectMapperPresent) ? initObjectMapper(config) : null;
- this.jsonManager = (objectMapperPresent) ? new TypeJsonManager(postgres, objectMapper, config.isJsonDirtyByDefault()) : null;
+ this.jsonManager = (objectMapperPresent) ? new TypeJsonManager(postgres, objectMapper) : null;
this.extraTypeFactory = new DefaultTypeFactory(config);
this.arrayTypeListFactory = arrayTypeListFactory(config.getDatabasePlatform());
this.arrayTypeSetFactory = arrayTypeSetFactory(config.getDatabasePlatform());
@@ -556,7 +556,7 @@ public final class DefaultTypeManager implements TypeManager {
// no override or further mapping required
return scalarType;
}
- ScalarTypeEnum> scalarEnum = (ScalarTypeEnum>)scalarType;
+ ScalarTypeEnum> scalarEnum = (ScalarTypeEnum>) scalarType;
if (scalarEnum != null && !scalarEnum.isOverrideBy(type)) {
if (type != null && !scalarEnum.isCompatible(type)) {
throw new IllegalStateException("Error mapping Enum type:" + enumType + " It is mapped using 2 different modes when only one is supported (ORDINAL, STRING or an Ebean mapping)");
@@ -673,7 +673,7 @@ public final class DefaultTypeManager implements TypeManager {
private Object initObjectMapper(DatabaseConfig config) {
Object objectMapper = config.getObjectMapper();
if (objectMapper == null) {
- objectMapper = new ObjectMapper();
+ objectMapper = InitObjectMapper.init();
config.setObjectMapper(objectMapper);
}
return objectMapper;
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/InitObjectMapper.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/InitObjectMapper.java
new file mode 100644
index 000000000..90a86ec79
--- /dev/null
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/InitObjectMapper.java
@@ -0,0 +1,22 @@
+package io.ebeaninternal.server.type;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * Initialise the Jackson ObjectMapper.
+ */
+class InitObjectMapper {
+
+ /**
+ * Create and return the default ObjectMapper.
+ */
+ static Object init() {
+ SimpleModule module = new SimpleModule();
+ module.addAbstractTypeMapping(Set.class, LinkedHashSet.class);
+ return new ObjectMapper().registerModule(module);
+ }
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java
index 7fb3aa4b4..334f4b232 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java
@@ -13,9 +13,6 @@ import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.ScalarType;
import io.ebean.text.TextException;
-import io.ebeaninternal.json.ModifyAwareList;
-import io.ebeaninternal.json.ModifyAwareMap;
-import io.ebeaninternal.json.ModifyAwareSet;
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
import javax.persistence.PersistenceException;
@@ -24,9 +21,6 @@ import java.io.DataOutput;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Types;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
/**
* Supports @DbJson properties using Jackson ObjectMapper.
@@ -38,25 +32,14 @@ class ScalarTypeJsonObjectMapper {
*/
static ScalarType> createTypeFor(TypeJsonManager jsonManager, DeployBeanProperty prop, int dbType, DocPropertyType docType) {
AnnotatedField field = (AnnotatedField) prop.getJacksonField();
- Class> type = field.getRawType();
-
MutationDetection mode = prop.getMutationDetection();
if (mode == MutationDetection.NONE) {
- return new NoMutationDetection(jsonManager, field, dbType, type);
+ return new NoMutationDetection(jsonManager, field, dbType, docType);
} else if (mode != MutationDetection.DEFAULT) {
- return new GenericObject(jsonManager, field, dbType, type);
- }
- if (Set.class.equals(type)) {
- return new OmSet(jsonManager, field, dbType, docType);
- }
- if (List.class.equals(type)) {
- return new OmList(jsonManager, field, dbType, docType);
- }
- if (Map.class.equals(type)) {
- return new OmMap(jsonManager, field, dbType);
+ return new GenericObject(jsonManager, field, dbType, docType);
}
prop.setMutationDetection(MutationDetection.HASH);
- return new GenericObject(jsonManager, field, dbType, type);
+ return new GenericObject(jsonManager, field, dbType, docType);
}
/**
@@ -64,8 +47,8 @@ class ScalarTypeJsonObjectMapper {
*/
private static class NoMutationDetection extends Base