diff --git a/composites/ebean/pom.xml b/composites/ebean/pom.xml
index 79af0a90e..ca1393dc6 100644
--- a/composites/ebean/pom.xml
+++ b/composites/ebean/pom.xml
@@ -37,6 +37,12 @@
13.9.3-SNAPSHOT
+
+ io.ebean
+ ebean-jackson-mapper
+ 13.9.3-SNAPSHOT
+
+
io.ebean
ebean-datasource
diff --git a/ebean-bom/pom.xml b/ebean-bom/pom.xml
index 8303d86a7..cba3f7ed8 100644
--- a/ebean-bom/pom.xml
+++ b/ebean-bom/pom.xml
@@ -122,6 +122,12 @@
13.9.3-SNAPSHOT
+
+ io.ebean
+ ebean-jackson-mapper
+ 13.9.3-SNAPSHOT
+
+
io.ebean
ebean-ddl-generator
diff --git a/ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonManager.java b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonManager.java
new file mode 100644
index 000000000..f0e645d1d
--- /dev/null
+++ b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonManager.java
@@ -0,0 +1,24 @@
+package io.ebean.core.type;
+
+import io.ebean.annotation.MutationDetection;
+
+/**
+ * Holds the configured mapper and default mutation detection mode to be used.
+ */
+public interface ScalarJsonManager {
+
+ /**
+ * Return the default mutation detection mode.
+ */
+ MutationDetection mutationDetection();
+
+ /**
+ * Return the object mapper supplied in DatabaseConfig.
+ */
+ Object mapper();
+
+ /**
+ * Return the Postgres type given the jdbc type.
+ */
+ String postgresType(int dbType);
+}
diff --git a/ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonMapper.java b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonMapper.java
new file mode 100644
index 000000000..5a027ff96
--- /dev/null
+++ b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonMapper.java
@@ -0,0 +1,23 @@
+package io.ebean.core.type;
+
+import io.avaje.lang.Nullable;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Supports JSON bean properties that use something like Jackson ObjectMapper to convert between
+ * JSON content and the logical bean property value.
+ */
+public interface ScalarJsonMapper {
+
+ /**
+ * Return a ScalarType for the given JSON property.
+ */
+ ScalarType> createType(ScalarJsonRequest request);
+
+ /**
+ * Return a marker annotation to detect when the JSON mapper should be used explicitly.
+ */
+ @Nullable
+ Class markerAnnotation();
+}
diff --git a/ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonRequest.java b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonRequest.java
new file mode 100644
index 000000000..c47681fd1
--- /dev/null
+++ b/ebean-core-type/src/main/java/io/ebean/core/type/ScalarJsonRequest.java
@@ -0,0 +1,67 @@
+package io.ebean.core.type;
+
+import io.ebean.annotation.MutationDetection;
+
+/**
+ * A request to create a ScalarType for a bean property (typically annotated with {@code @DbJson}).
+ */
+public final class ScalarJsonRequest {
+
+ private final ScalarJsonManager manager;
+ private final int dbType;
+ private final DocPropertyType docType;
+ private final Class> beanType;
+ private final MutationDetection mode;
+ private final String name;
+
+ public ScalarJsonRequest(ScalarJsonManager manager, int dbType, DocPropertyType docType, Class> beanType, MutationDetection mode, String name) {
+ this.manager = manager;
+ this.dbType = dbType;
+ this.docType = docType;
+ this.beanType = beanType;
+ this.mode = mode;
+ this.name = name;
+ }
+
+ /**
+ * Return the manager.
+ */
+ public ScalarJsonManager manager() {
+ return manager;
+ }
+
+ /**
+ * Return the jdbc type this property maps to (e.g. JSON, JSONB etc).
+ */
+ public int dbType() {
+ return dbType;
+ }
+
+ /**
+ * Return the document store docType.
+ */
+ public DocPropertyType docType() {
+ return docType;
+ }
+
+ /**
+ * Return the type of the bean that this property belongs to.
+ */
+ public Class> beanType() {
+ return beanType;
+ }
+
+ /**
+ * Return the mutation detection mode the property should use.
+ */
+ public MutationDetection mode() {
+ return mode;
+ }
+
+ /**
+ * Return the property name.
+ */
+ public String name() {
+ return name;
+ }
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java
index 49767439f..dfeacbd83 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanDescriptor.java
@@ -152,7 +152,6 @@ public class DeployBeanDescriptor {
private DocStoreMode docStoreDelete;
private DeployBeanProperty idProperty;
private TableJoin primaryKeyJoin;
- private Object jacksonAnnotatedClass;
/**
* Construct the BeanDescriptor.
@@ -1130,14 +1129,4 @@ public class DeployBeanDescriptor {
}
}
- /**
- * Returns the jackson annotated class, if jackson is present.
- */
- @SuppressWarnings("unchecked")
- Object /*AnnotatedClass*/ getJacksonAnnotatedClass() {
- if (jacksonAnnotatedClass == null) {
- jacksonAnnotatedClass = new DeployBeanObtainJackson(config, beanType).obtain();
- }
- return jacksonAnnotatedClass;
- }
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java
index 847401b1c..2507387ab 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanProperty.java
@@ -1042,20 +1042,6 @@ public class DeployBeanProperty {
this.elementProperty = true;
}
- /**
- * Returns the jackson annotated field, if jackson is present.
- */
- public Object /*AnnotatedField*/ getJacksonField() {
- com.fasterxml.jackson.databind.introspect.AnnotatedClass jac =
- (com.fasterxml.jackson.databind.introspect.AnnotatedClass) getDesc().getJacksonAnnotatedClass();
- for (com.fasterxml.jackson.databind.introspect.AnnotatedField candidate : jac.fields()) {
- if (candidate.getName().equals(getName())) {
- return candidate;
- }
- }
- return null;
- }
-
public void initMetaAnnotations(Set> metaAnnotationsFilter) {
metaAnnotations = AnnotationUtil.metaFindAllFor(field, metaAnnotationsFilter);
}
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 29685ea99..c60386f30 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
@@ -65,13 +65,14 @@ public final class DefaultTypeManager implements TypeManager {
private final Object objectMapper;
private final boolean objectMapperPresent;
private final boolean postgres;
- private final TypeJsonManager jsonManager;
+ private final ScalarJsonManager jsonManager;
private final boolean offlineMigrationGeneration;
private final EnumType defaultEnumType;
private final DatabasePlatform databasePlatform;
private final PlatformArrayTypeFactory arrayTypeListFactory;
private final PlatformArrayTypeFactory arrayTypeSetFactory;
+ private final ScalarJsonMapper jsonMapper;
private GeoTypeBinder geoTypeBinder;
/**
@@ -94,6 +95,9 @@ public final class DefaultTypeManager implements TypeManager {
this.offlineMigrationGeneration = DbOffline.isGenerateMigration();
this.defaultEnumType = config.getDefaultEnumType();
+ ServiceLoader mappers = ServiceLoader.load(ScalarJsonMapper.class);
+ jsonMapper = mappers.findFirst().orElse(null);
+
initialiseStandard(config);
initialiseJavaTimeTypes(config);
loadTypesFromProviders(config, objectMapper);
@@ -293,34 +297,24 @@ public final class DefaultTypeManager implements TypeManager {
@Override
public ScalarType> dbJsonType(DeployBeanProperty prop, int dbType, int dbLength) {
Class> type = prop.getPropertyType();
- Type genericType = prop.getGenericType();
- boolean hasJacksonAnnotations = objectMapperPresent && checkJacksonAnnotations(prop);
-
if (type.equals(String.class)) {
return ScalarTypeJsonString.typeFor(postgres, dbType);
}
- if (type.equals(List.class)) {
- DocPropertyType docType = docType(genericType);
- if (!hasJacksonAnnotations && isValueTypeSimple(genericType)) {
- return ScalarTypeJsonList.typeFor(postgres, dbType, docType, prop.isNullable(), jsonManager.keepSource(prop));
- } else {
- return createJsonObjectMapperType(prop, dbType, docType);
+ if (jsonMapper != null) {
+ var markerAnnotation = jsonMapper.markerAnnotation();
+ if (markerAnnotation != null && !prop.getMetaAnnotations(markerAnnotation).isEmpty()) {
+ return createJsonObjectMapperType(prop, dbType, docPropertyType(prop, type));
}
}
- if (type.equals(Set.class)) {
- DocPropertyType docType = docType(genericType);
- if (!hasJacksonAnnotations && isValueTypeSimple(genericType)) {
- return ScalarTypeJsonSet.typeFor(postgres, dbType, docType, prop.isNullable(), jsonManager.keepSource(prop));
- } else {
- return createJsonObjectMapperType(prop, dbType, docType);
- }
+ Type genericType = prop.getGenericType();
+ if (type.equals(List.class) && isValueTypeSimple(genericType)) {
+ return ScalarTypeJsonList.typeFor(postgres, dbType, docType(genericType), prop.isNullable(), keepSource(prop));
}
- if (type.equals(Map.class)) {
- if (!hasJacksonAnnotations && isMapValueTypeObject(genericType)) {
- return ScalarTypeJsonMap.typeFor(postgres, dbType, jsonManager.keepSource(prop));
- } else {
- return createJsonObjectMapperType(prop, dbType, DocPropertyType.OBJECT);
- }
+ if (type.equals(Set.class) && isValueTypeSimple(genericType)) {
+ return ScalarTypeJsonSet.typeFor(postgres, dbType, docType(genericType), prop.isNullable(), keepSource(prop));
+ }
+ if (type.equals(Map.class) && isMapValueTypeObject(genericType)) {
+ return ScalarTypeJsonMap.typeFor(postgres, dbType, keepSource(prop));
}
if (objectMapperPresent && prop.getMutationDetection() == MutationDetection.DEFAULT) {
ScalarTypeSet> typeSet = typeSets.get(type);
@@ -331,12 +325,15 @@ public final class DefaultTypeManager implements TypeManager {
return createJsonObjectMapperType(prop, dbType, DocPropertyType.OBJECT);
}
- /**
- * Returns TRUE, if there is any jackson annotation on that property. All jackson annotations
- * are annotated with the @JacksonAnnotation meta annotation. So detection is easy.
- */
- private boolean checkJacksonAnnotations(DeployBeanProperty prop) {
- return prop.getMetaAnnotation(com.fasterxml.jackson.annotation.JacksonAnnotation.class) != null;
+ private boolean keepSource(DeployBeanProperty prop) {
+ if (prop.getMutationDetection() == MutationDetection.DEFAULT) {
+ prop.setMutationDetection(jsonManager.mutationDetection());
+ }
+ return prop.getMutationDetection() == MutationDetection.SOURCE;
+ }
+
+ private DocPropertyType docPropertyType(DeployBeanProperty prop, Class> type) {
+ return type.equals(List.class) || type.equals(Set.class) ? docType(prop.getGenericType()) : DocPropertyType.OBJECT;
}
private DocPropertyType docType(Type genericType) {
@@ -370,11 +367,14 @@ public final class DefaultTypeManager implements TypeManager {
}
private ScalarType> createJsonObjectMapperType(DeployBeanProperty prop, int dbType, DocPropertyType docType) {
- Class> type = prop.getPropertyType();
- if (objectMapper == null) {
- throw new IllegalArgumentException("Type [" + type + "] unsupported for @DbJson mapping - Jackson ObjectMapper not present");
+ if (jsonMapper == null) {
+ throw new IllegalArgumentException("Unsupported @DbJson mapping - Jackson ObjectMapper not present for " + prop);
}
- return ScalarTypeJsonObjectMapper.createTypeFor(jsonManager, prop, dbType, docType);
+ if (MutationDetection.DEFAULT == prop.getMutationDetection()) {
+ prop.setMutationDetection(jsonManager.mutationDetection());
+ }
+ var req = new ScalarJsonRequest(jsonManager, dbType, docType, prop.getDesc().getBeanType(), prop.getMutationDetection(), prop.getName());
+ return jsonMapper.createType(req);
}
/**
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/TypeJsonManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/TypeJsonManager.java
index 84ceac12b..2b5a61432 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/TypeJsonManager.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/TypeJsonManager.java
@@ -1,44 +1,35 @@
package io.ebeaninternal.server.type;
-import com.fasterxml.jackson.databind.ObjectMapper;
import io.ebean.ModifyAwareType;
import io.ebean.annotation.MutationDetection;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebean.core.type.PostgresHelper;
-import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
+import io.ebean.core.type.ScalarJsonManager;
-final class TypeJsonManager {
+final class TypeJsonManager implements ScalarJsonManager {
private final boolean postgres;
- private final ObjectMapper objectMapper;
+ private final Object mapper;
private final MutationDetection mutationDetection;
- TypeJsonManager(boolean postgres, Object objectMapper, MutationDetection mutationDetection) {
+ TypeJsonManager(boolean postgres, Object mapper, MutationDetection mutationDetection) {
this.postgres = postgres;
- this.objectMapper = (ObjectMapper) objectMapper;
+ this.mapper = mapper;
this.mutationDetection = mutationDetection;
}
- MutationDetection mutationDetection() {
+ @Override
+ public MutationDetection mutationDetection() {
return mutationDetection;
}
- ObjectMapper objectMapper() {
- return objectMapper;
+ @Override
+ public Object mapper() {
+ return mapper;
}
- boolean keepSource(DeployBeanProperty prop) {
- if (prop.getMutationDetection() == MutationDetection.SOURCE) {
- return true;
- } else if (prop.getMutationDetection() == MutationDetection.DEFAULT) {
- prop.setMutationDetection(mutationDetection);
- return mutationDetection == MutationDetection.SOURCE;
- } else {
- return false;
- }
- }
-
- String postgresType(int dbType) {
+ @Override
+ public String postgresType(int dbType) {
if (postgres) {
switch (dbType) {
case DbPlatformType.JSON:
diff --git a/ebean-core/src/main/java/module-info.java b/ebean-core/src/main/java/module-info.java
index 58a3438c9..d09920dd5 100644
--- a/ebean-core/src/main/java/module-info.java
+++ b/ebean-core/src/main/java/module-info.java
@@ -9,6 +9,7 @@ module io.ebean.core {
uses io.ebean.datasource.DataSourceAlertFactory;
uses io.ebean.core.type.ExtraTypeFactory;
uses io.ebean.core.type.ScalarTypeSetFactory;
+ uses io.ebean.core.type.ScalarJsonMapper;
uses io.ebeanservice.docstore.api.DocStoreFactory;
uses io.ebean.migration.auto.AutoMigrationRunner;
uses io.avaje.classpath.scanner.ClassPathScannerFactory;
diff --git a/ebean-jackson-mapper/pom.xml b/ebean-jackson-mapper/pom.xml
new file mode 100644
index 000000000..9371f4a86
--- /dev/null
+++ b/ebean-jackson-mapper/pom.xml
@@ -0,0 +1,46 @@
+
+
+
+ ebean-parent
+ io.ebean
+ 13.9.3-SNAPSHOT
+
+ 4.0.0
+
+ ebean-jackson-mapper
+
+
+
+
+ io.ebean
+ ebean-core-type
+ 13.9.3-SNAPSHOT
+ provided
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson.version}
+ provided
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+ provided
+
+
+
+ io.avaje
+ junit
+ 1.1
+ test
+
+
+
+
+
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanObtainJackson.java b/ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/AnnotatedClassUtil.java
similarity index 58%
rename from ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanObtainJackson.java
rename to ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/AnnotatedClassUtil.java
index 9bbfb6007..bd30d88fd 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployBeanObtainJackson.java
+++ b/ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/AnnotatedClassUtil.java
@@ -1,28 +1,19 @@
-package io.ebeaninternal.server.deploy.meta;
+package io.ebean.jackson.mapper;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.introspect.AnnotatedClass;
import com.fasterxml.jackson.databind.introspect.AnnotatedClassResolver;
-import io.ebean.config.DatabaseConfig;
/**
* Used to obtain the Jackson AnnotatedClass for a given bean type utlimately to obtain field level Jackson annotations.
*/
-final class DeployBeanObtainJackson {
-
- private final DatabaseConfig config;
- private final Class beanType;
-
- DeployBeanObtainJackson(DatabaseConfig config, Class beanType) {
- this.config = config;
- this.beanType = beanType;
- }
+final class AnnotatedClassUtil {
/**
* Return the Jackson AnnotatedClass for the given bean type.
*/
- Object obtain() {
- ObjectMapper objectMapper = (ObjectMapper) config.getObjectMapper();
+ static AnnotatedClass obtain(ObjectMapper objectMapper, Class> beanType) {
JavaType javaType = objectMapper.getTypeFactory().constructType(beanType);
return AnnotatedClassResolver.resolve(objectMapper.getDeserializationConfig(), javaType, objectMapper.getDeserializationConfig());
}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/JacksonTypeHelper.java b/ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/JacksonTypeHelper.java
similarity index 97%
rename from ebean-core/src/main/java/io/ebeaninternal/server/type/JacksonTypeHelper.java
rename to ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/JacksonTypeHelper.java
index 7d2d5b3e1..11f8cc0a8 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/JacksonTypeHelper.java
+++ b/ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/JacksonTypeHelper.java
@@ -1,4 +1,4 @@
-package io.ebeaninternal.server.type;
+package io.ebean.jackson.mapper;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.AnnotatedField;
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/JsonTrim.java b/ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/JsonTrim.java
similarity index 95%
rename from ebean-core/src/main/java/io/ebeaninternal/server/type/JsonTrim.java
rename to ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/JsonTrim.java
index ec0808f14..855978681 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/JsonTrim.java
+++ b/ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/JsonTrim.java
@@ -1,4 +1,4 @@
-package io.ebeaninternal.server.type;
+package io.ebean.jackson.mapper;
/**
* Helper that removes whitespace from JSON. Used to normalise Postgres JSONB content.
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java b/ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/ScalarJsonJacksonMapper.java
similarity index 74%
rename from ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java
rename to ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/ScalarJsonJacksonMapper.java
index 2615e5e28..a4dfbac9a 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/type/ScalarTypeJsonObjectMapper.java
+++ b/ebean-jackson-mapper/src/main/java/io/ebean/jackson/mapper/ScalarJsonJacksonMapper.java
@@ -1,4 +1,4 @@
-package io.ebeaninternal.server.type;
+package io.ebean.jackson.mapper;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
@@ -6,42 +6,63 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
+import com.fasterxml.jackson.databind.introspect.AnnotatedClass;
import com.fasterxml.jackson.databind.introspect.AnnotatedField;
import io.ebean.annotation.MutationDetection;
import io.ebean.core.type.*;
import io.ebean.text.TextException;
-import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
import javax.persistence.PersistenceException;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
+import java.lang.annotation.Annotation;
import java.sql.SQLException;
import java.sql.Types;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
/**
* Supports @DbJson properties using Jackson ObjectMapper.
*/
-final class ScalarTypeJsonObjectMapper {
+public final class ScalarJsonJacksonMapper implements ScalarJsonMapper {
+
+ private final Map, AnnotatedClass> jacksonClasses = new ConcurrentHashMap<>();
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class markerAnnotation() {
+ return (Class)com.fasterxml.jackson.annotation.JacksonAnnotation.class;
+ }
/**
* Create and return the appropriate ScalarType.
*/
- static ScalarType> createTypeFor(TypeJsonManager jsonManager, DeployBeanProperty prop, int dbType, DocPropertyType docType) {
- AnnotatedField field = (AnnotatedField) prop.getJacksonField();
- MutationDetection mode = prop.getMutationDetection();
- if (mode == MutationDetection.NONE) {
- return new NoMutationDetection(jsonManager, field, dbType, docType);
- } else if (mode != MutationDetection.DEFAULT) {
- return new GenericObject(jsonManager, field, dbType, docType);
+ @Override
+ public ScalarType> createType(ScalarJsonRequest req) {
+ AnnotatedClass annotatedClass = annotatedClass(req);
+ AnnotatedField field = annotatedField(annotatedClass, req);
+ if (req.mode() == MutationDetection.NONE) {
+ return new NoMutationDetection(req.manager(), field, req.dbType(), req.docType());
+ } else {
+ return new GenericObject(req.manager(), field, req.dbType(), req.docType());
}
- // using the global default MutationDetection mode (defaults to HASH)
- final MutationDetection defaultMode = jsonManager.mutationDetection();
- prop.setMutationDetection(defaultMode);
- if (MutationDetection.NONE == defaultMode) {
- return new NoMutationDetection(jsonManager, field, dbType, docType);
+ }
+
+ private AnnotatedField annotatedField(AnnotatedClass annotatedClass, ScalarJsonRequest req) {
+ for (AnnotatedField field : annotatedClass.fields()) {
+ if (field.getName().equals(req.name())) {
+ return field;
+ }
}
- return new GenericObject(jsonManager, field, dbType, docType);
+ throw new IllegalStateException("AnnotatedField not found to match " + req.name());
+ }
+
+ private AnnotatedClass annotatedClass(ScalarJsonRequest req) {
+ return jacksonClasses.computeIfAbsent(req.beanType(), key -> {
+ ObjectMapper mapper = (ObjectMapper) req.manager().mapper();
+ return AnnotatedClassUtil.obtain(mapper, req.beanType());
+ });
}
/**
@@ -49,7 +70,7 @@ final class ScalarTypeJsonObjectMapper {
*/
private static final class NoMutationDetection extends Base
+
+ io.ebean
+ ebean-jackson-mapper
+ 13.9.3-SNAPSHOT
+ test
+
+
io.ebean
ebean-platform-all
diff --git a/pom.xml b/pom.xml
index 47f1683f9..f3ceafc4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,6 +92,7 @@
ebean-joda-time
ebean-csv-reader
ebean-jackson-jsonnode
+ ebean-jackson-mapper