Support for jMolecules' Association type.
We no recognize properties of type org.jmolecules.ddd.types.Association as associations in our PersistentProperty model. Also, we now register JMolecules Converter implementations for Association and Identifier in CustomConversions so that they can persisted like their embedded primitive value out of the box. Fixes #2315. Original pull request: #2316.
This commit is contained in:
committed by
Mark Paluch
parent
3f1609587e
commit
6b0292cc66
@@ -43,9 +43,13 @@ import org.springframework.util.Assert;
|
||||
public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>> implements PersistentProperty<P> {
|
||||
|
||||
private static final Field CAUSE_FIELD;
|
||||
private static final Class<?> ASSOCIATION_TYPE;
|
||||
|
||||
static {
|
||||
|
||||
CAUSE_FIELD = ReflectionUtils.findRequiredField(Throwable.class, "cause");
|
||||
ASSOCIATION_TYPE = ReflectionUtils.loadIfPresent("org.jmolecules.ddd.types.Association",
|
||||
AbstractPersistentProperty.class.getClassLoader());
|
||||
}
|
||||
|
||||
private final String name;
|
||||
@@ -241,7 +245,8 @@ public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>
|
||||
*/
|
||||
@Override
|
||||
public boolean isAssociation() {
|
||||
return isAnnotationPresent(Reference.class);
|
||||
return isAnnotationPresent(Reference.class) //
|
||||
|| ASSOCIATION_TYPE != null && ASSOCIATION_TYPE.isAssignableFrom(rawType);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -70,7 +70,8 @@ public abstract class AnnotationBasedPersistentProperty<P extends PersistentProp
|
||||
|
||||
private final Lazy<Boolean> isWritable = Lazy
|
||||
.of(() -> !isTransient() && !isAnnotationPresent(ReadOnlyProperty.class));
|
||||
private final Lazy<Boolean> isReference = Lazy.of(() -> !isTransient() && isAnnotationPresent(Reference.class));
|
||||
private final Lazy<Boolean> isReference = Lazy.of(() -> !isTransient() //
|
||||
&& (isAnnotationPresent(Reference.class) || super.isAssociation()));
|
||||
private final Lazy<Boolean> isId = Lazy.of(() -> isAnnotationPresent(Id.class));
|
||||
private final Lazy<Boolean> isVersion = Lazy.of(() -> isAnnotationPresent(Version.class));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user