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 75112ab07a..d497656020 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
@@ -265,7 +265,7 @@ public GeoTypeBinder geoTypeBinder() {
@Override
public ScalarType> dbMapType() {
- return hstoreSupport() ? hstoreType : ScalarTypeJsonMap.typeFor(false, Types.VARCHAR, false);
+ return hstoreSupport() ? hstoreType : ScalarTypeJsonMap.typeFor(false, Types.VARCHAR, MutationDetection.DEFAULT);
}
@Override
@@ -322,17 +322,17 @@ public ScalarType> dbJsonType(DeployProperty prop, int dbType, int dbLength) {
}
Type genericType = prop.genericType();
if (type.equals(List.class) && isValueTypeSimple(genericType)) {
- return ScalarTypeJsonList.typeFor(postgres, dbType, docType(genericType), prop.isNullable(), keepSource(prop));
+ return ScalarTypeJsonList.typeFor(postgres, dbType, docType(genericType), prop.isNullable(), collectionMutationDetection(prop));
}
if (type.equals(Set.class) && isValueTypeSimple(genericType)) {
- return ScalarTypeJsonSet.typeFor(postgres, dbType, docType(genericType), prop.isNullable(), keepSource(prop));
+ return ScalarTypeJsonSet.typeFor(postgres, dbType, docType(genericType), prop.isNullable(), collectionMutationDetection(prop));
}
if (type.equals(Map.class) && isBuiltinJsonMap(genericType)) {
Type keyType = TypeReflectHelper.getMapKeyTypeRaw(genericType);
if (isEnumType(keyType)) {
- return enumJsonMapType(postgres, dbType, keyType, keepSource(prop));
+ return enumJsonMapType(postgres, dbType, keyType, collectionMutationDetection(prop));
}
- return ScalarTypeJsonMap.typeFor(postgres, dbType, keepSource(prop));
+ return ScalarTypeJsonMap.typeFor(postgres, dbType, collectionMutationDetection(prop));
}
if (objectMapperPresent && prop.mutationDetection() == MutationDetection.DEFAULT) {
ScalarTypeSet> typeSet = typeSets.get(type);
@@ -343,18 +343,25 @@ public ScalarType> dbJsonType(DeployProperty prop, int dbType, int dbLength) {
return createJsonObjectMapperType(prop, dbType, DocPropertyType.OBJECT);
}
- private boolean keepSource(DeployProperty prop) {
- if (prop.mutationDetection() == MutationDetection.DEFAULT) {
- prop.setMutationDetection(jsonManager != null ? jsonManager.mutationDetection() : MutationDetection.NONE);
- }
- return prop.mutationDetection() == MutationDetection.SOURCE;
+ /**
+ * Return the mutation detection mode to use for the built-in JSON collection types
+ * (Map, List, Set).
+ *
+ * Unlike {@code @DbJson} properties handled via the Jackson ObjectMapper, {@code DEFAULT}
+ * on these collection types is not resolved against the DatabaseConfig wide
+ * default - it always uses the legacy ModifyAware wrapper based dirty checking. Only an
+ * explicit {@code NONE}, {@code HASH} or {@code SOURCE} on the property itself switches
+ * these types away from ModifyAware based checking.
+ */
+ private MutationDetection collectionMutationDetection(DeployProperty prop) {
+ return prop.mutationDetection();
}
@SuppressWarnings("unchecked")
- private ScalarType> enumJsonMapType(boolean postgres, int dbType, Type keyType, boolean keepSource) {
+ private ScalarType> enumJsonMapType(boolean postgres, int dbType, Type keyType, MutationDetection mutationDetection) {
Class extends Enum>> enumClass = asEnumClass(keyType);
ScalarType extends Enum>> enumScalarType = (ScalarType extends Enum>>) enumType(enumClass, null);
- return ScalarTypeJsonMapEnum.typeFor(postgres, dbType, enumScalarType, keepSource);
+ return ScalarTypeJsonMapEnum.typeFor(postgres, dbType, enumScalarType, mutationDetection);
}
private DocPropertyType docPropertyType(DeployProperty prop, Class> type) {
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/PlatformArrayTypeJsonList.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/PlatformArrayTypeJsonList.java
index 5df3364410..636d55b01b 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/PlatformArrayTypeJsonList.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/PlatformArrayTypeJsonList.java
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.type;
+import io.ebean.annotation.MutationDetection;
import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.ScalarType;
@@ -27,15 +28,14 @@ private DocPropertyType docType(Type valueType) {
@Override
public ScalarType> typeFor(Type valueType, boolean nullable) {
if (valueType.equals(UUID.class)) {
- // TODO: keepSource for @DbArray?
- return new ScalarTypeJsonList.VarcharWithConverter(DocPropertyType.UUID, nullable, false, ArrayElementConverter.UUID);
+ return new ScalarTypeJsonList.VarcharWithConverter(DocPropertyType.UUID, nullable, ArrayElementConverter.UUID);
}
- return new ScalarTypeJsonList(java.sql.Types.VARCHAR, JsonStorage.VARCHAR, docType(valueType), nullable, false);
+ return new ScalarTypeJsonList(java.sql.Types.VARCHAR, JsonStorage.VARCHAR, docType(valueType), nullable, MutationDetection.DEFAULT);
}
@Override
public ScalarType> typeForEnum(ScalarType> scalarType, boolean nullable) {
final ArrayElementConverter.EnumConverter converter = new ArrayElementConverter.EnumConverter(scalarType);
- return new ScalarTypeJsonList.VarcharWithConverter(scalarType.docType(), nullable, false, converter);
+ return new ScalarTypeJsonList.VarcharWithConverter(scalarType.docType(), nullable, converter);
}
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/PlatformArrayTypeJsonSet.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/PlatformArrayTypeJsonSet.java
index 314efc4747..b448829e4b 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/PlatformArrayTypeJsonSet.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/PlatformArrayTypeJsonSet.java
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.type;
+import io.ebean.annotation.MutationDetection;
import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.ScalarType;
@@ -27,15 +28,14 @@ private DocPropertyType docType(Type valueType) {
@Override
public ScalarType> typeFor(Type valueType, boolean nullable) {
if (valueType.equals(UUID.class)) {
- // TODO: keepSource for @DbArray?
- return new ScalarTypeJsonSet.VarcharWithConverter(DocPropertyType.UUID, nullable, false, ArrayElementConverter.UUID);
+ return new ScalarTypeJsonSet.VarcharWithConverter(DocPropertyType.UUID, nullable, ArrayElementConverter.UUID);
}
- return new ScalarTypeJsonSet(java.sql.Types.VARCHAR, JsonStorage.VARCHAR, docType(valueType), nullable, false);
+ return new ScalarTypeJsonSet(java.sql.Types.VARCHAR, JsonStorage.VARCHAR, docType(valueType), nullable, MutationDetection.DEFAULT);
}
@Override
public ScalarType> typeForEnum(ScalarType> scalarType, boolean nullable) {
final ArrayElementConverter.EnumConverter converter = new ArrayElementConverter.EnumConverter(scalarType);
- return new ScalarTypeJsonSet.VarcharWithConverter(scalarType.docType(), nullable, false, converter);
+ return new ScalarTypeJsonSet.VarcharWithConverter(scalarType.docType(), nullable, converter);
}
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonCollectionValue.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonCollectionValue.java
index 052638444a..fa2e2289cc 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonCollectionValue.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonCollectionValue.java
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.type;
+import io.ebean.annotation.MutationDetection;
import io.ebean.core.type.DocPropertyType;
/**
@@ -10,9 +11,9 @@
*/
abstract class ScalarTypeJsonCollectionValue extends ScalarTypeJsonValue implements ScalarTypeArray {
- ScalarTypeJsonCollectionValue(Class type, int jdbcType, JsonStorage storage, boolean keepSource,
+ ScalarTypeJsonCollectionValue(Class type, int jdbcType, JsonStorage storage, MutationDetection mutationDetection,
boolean nullable, DocPropertyType docType) {
- super(type, jdbcType, storage, keepSource, nullable, "[]", docType);
+ super(type, jdbcType, storage, mutationDetection, nullable, "[]", docType);
}
@Override
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonList.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonList.java
index d994b214d0..5ad7326f37 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonList.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonList.java
@@ -2,6 +2,7 @@
import io.avaje.json.JsonReader;
import io.avaje.json.JsonWriter;
+import io.ebean.annotation.MutationDetection;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.PostgresHelper;
@@ -25,20 +26,20 @@ class ScalarTypeJsonList extends ScalarTypeJsonCollectionValue {
/**
* Return the appropriate ScalarType for the requested dbType and platform.
*/
- static ScalarType> typeFor(boolean postgres, int dbType, DocPropertyType docType, boolean nullable, boolean keepSource) {
+ static ScalarType> typeFor(boolean postgres, int dbType, DocPropertyType docType, boolean nullable, MutationDetection mutationDetection) {
if (postgres) {
switch (dbType) {
case DbPlatformType.JSONB:
- return new ScalarTypeJsonList(DbPlatformType.JSONB, JsonStorage.postgres(PostgresHelper.JSONB_TYPE), docType, nullable, keepSource);
+ return new ScalarTypeJsonList(DbPlatformType.JSONB, JsonStorage.postgres(PostgresHelper.JSONB_TYPE), docType, nullable, mutationDetection);
case DbPlatformType.JSON:
- return new ScalarTypeJsonList(DbPlatformType.JSON, JsonStorage.postgres(PostgresHelper.JSON_TYPE), docType, nullable, keepSource);
+ return new ScalarTypeJsonList(DbPlatformType.JSON, JsonStorage.postgres(PostgresHelper.JSON_TYPE), docType, nullable, mutationDetection);
}
}
- return new ScalarTypeJsonList(Types.VARCHAR, JsonStorage.VARCHAR, docType, nullable, keepSource);
+ return new ScalarTypeJsonList(Types.VARCHAR, JsonStorage.VARCHAR, docType, nullable, mutationDetection);
}
- ScalarTypeJsonList(int jdbcType, JsonStorage storage, DocPropertyType docType, boolean nullable, boolean keepSource) {
- super(List.class, jdbcType, storage, keepSource, nullable, docType);
+ ScalarTypeJsonList(int jdbcType, JsonStorage storage, DocPropertyType docType, boolean nullable, MutationDetection mutationDetection) {
+ super(List.class, jdbcType, storage, mutationDetection, nullable, docType);
}
@Override
@@ -87,8 +88,8 @@ static final class VarcharWithConverter extends ScalarTypeJsonList {
private final ArrayElementConverter converter;
- VarcharWithConverter(DocPropertyType docType, boolean nullable, boolean keepSource, ArrayElementConverter converter) {
- super(Types.VARCHAR, JsonStorage.VARCHAR, docType, nullable, keepSource);
+ VarcharWithConverter(DocPropertyType docType, boolean nullable, ArrayElementConverter converter) {
+ super(Types.VARCHAR, JsonStorage.VARCHAR, docType, nullable, MutationDetection.DEFAULT);
this.converter = converter;
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonMap.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonMap.java
index 52374a6d97..f743a04dc8 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonMap.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonMap.java
@@ -2,6 +2,7 @@
import io.avaje.json.JsonReader;
import io.avaje.json.JsonWriter;
+import io.ebean.annotation.MutationDetection;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.PostgresHelper;
@@ -22,8 +23,8 @@ class ScalarTypeJsonMap extends ScalarTypeJsonValue