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 4f927043c5..4a1499138a 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 @@ -35,7 +35,7 @@ * Description of a property of a bean. Includes its deployment information such * as database column mapping information. */ -public class DeployBeanProperty { +public class DeployBeanProperty implements DeployProperty { private static final int ID_ORDER = 1000000; private static final int UNIDIRECTIONAL_ORDER = 100000; @@ -226,6 +226,11 @@ public DeployBeanDescriptor> getDesc() { return desc; } + @Override + public Class> getOwnerType() { + return desc.getBeanType(); + } + /** * Return the DB column length for character columns. *
@@ -258,10 +263,12 @@ public void setJsonDeserialize(boolean jsonDeserialize) {
this.jsonDeserialize = jsonDeserialize;
}
+ @Override
public MutationDetection getMutationDetection() {
return mutationDetection;
}
+ @Override
public void setMutationDetection(MutationDetection dirtyDetection) {
this.mutationDetection = dirtyDetection;
}
@@ -476,8 +483,9 @@ public void setGeneratedProperty(GeneratedProperty generatedValue) {
}
/**
- * Return true if this property is mandatory.
+ * Return true if this property is not mandatory.
*/
+ @Override
public boolean isNullable() {
return nullable;
}
@@ -848,6 +856,7 @@ public Class> getPropertyType() {
/**
* Return the generic type for this property.
*/
+ @Override
public Type getGenericType() {
return genericType;
}
@@ -1052,6 +1061,7 @@ public A getMetaAnnotation(Class annotationType) {
return null;
}
+ @Override
@SuppressWarnings("unchecked")
public List getMetaAnnotations(Class annotationType) {
List result = new ArrayList<>();
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployProperty.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployProperty.java
new file mode 100644
index 0000000000..0fe3a4b8f1
--- /dev/null
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/meta/DeployProperty.java
@@ -0,0 +1,53 @@
+package io.ebeaninternal.server.deploy.meta;
+
+import io.ebean.annotation.MutationDetection;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.List;
+
+/**
+ * Property, with basic type information (BeanProperty and DtoProperty).
+ */
+public interface DeployProperty {
+
+ /**
+ * Return the name of the property.
+ */
+ String getName();
+
+ /**
+ * Return the generic type for this property.
+ */
+ Type getGenericType();
+
+ /**
+ * Return the property type.
+ */
+ Class> getPropertyType();
+
+ /**
+ * Returns the owner class of this property.
+ */
+ Class> getOwnerType();
+
+ /**
+ * Returns the annotations on this property.
+ */
+ List getMetaAnnotations(Class annotationType);
+
+ /**
+ * Returns the mutation detection setting of this property.
+ */
+ MutationDetection getMutationDetection();
+
+ /**
+ * Sets the mutation detection setting of this property.
+ */
+ void setMutationDetection(MutationDetection mutationDetection);
+
+ /**
+ * Return true if this property is not mandatory.
+ */
+ boolean isNullable();
+}
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java
index ba7937dc68..9fe23c0b1c 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/deploy/parse/DeployUtil.java
@@ -224,7 +224,7 @@ private void setDbJsonType(DeployBeanProperty prop, int dbType, int dbLength, Mu
/**
* Return the JDBC type for the JSON storage type.
*/
- private int dbJsonStorage(DbJsonType dbJsonType) {
+ public static int dbJsonStorage(DbJsonType dbJsonType) {
switch (dbJsonType) {
case JSONB:
return DbPlatformType.JSONB;
diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMetaBuilder.java b/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMetaBuilder.java
index 06929cefeb..bb6dde7fa3 100644
--- a/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMetaBuilder.java
+++ b/ebean-core/src/main/java/io/ebeaninternal/server/dto/DtoMetaBuilder.java
@@ -1,5 +1,7 @@
package io.ebeaninternal.server.dto;
+import io.ebean.annotation.DbJson;
+import io.ebean.annotation.DbJsonB;
import io.ebeaninternal.api.CoreLog;
import io.ebeaninternal.server.type.TypeManager;
@@ -21,10 +23,16 @@ final class DtoMetaBuilder {
private final Class> dtoType;
private final List
* For example Array based ScalarType for types like {@code List
* Note that type expected to be JsonNode or Map.
*
* for BasicJacksonType there exists two types and has a @JsonTypeInfo
* annotation. It is expected that this information is also honored by ebean.
*/
@@ -94,7 +151,8 @@ public void testPolymorph() throws IOException {
assertThat(found.getPlainValue()).isInstanceOf(LongJacksonType.class);
assertThat(found.getValueList()).hasSize(2);
assertThat(found.getValueSet()).hasSize(2);
- assertThat(found.getValueMap()).hasSize(2);;
+ assertThat(found.getValueMap()).hasSize(2);
+ ;
DB.save(bean);
@@ -103,7 +161,16 @@ public void testPolymorph() throws IOException {
assertThat(found.getPlainValue()).isInstanceOf(LongJacksonType.class);
assertThat(found.getValueList()).hasSize(2);
assertThat(found.getValueSet()).hasSize(2);
- assertThat(found.getValueMap()).hasSize(2);;
+ assertThat(found.getValueMap()).hasSize(2);
+
+
+ DtoJackson dto = DB.find(EBasicJsonJackson2.class).setId(bean.getId())
+ .select("valueSet,valueList,valueMap,plainValue").asDto(DtoJackson.class).findOne();
+
+ assertThat(dto.getPlainValue()).isInstanceOf(LongJacksonType.class);
+ assertThat(dto.getValueList()).hasSize(2);
+ assertThat(dto.getValueSet()).hasSize(2);
+ assertThat(dto.getValueMap()).hasSize(2);
}