|
|
|
|
@ -115,7 +115,7 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
@@ -115,7 +115,7 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
|
|
|
|
|
return asReference(constant, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected DBRef asReference(Object constant, Path<?> path) { |
|
|
|
|
protected DBRef asReference(Object constant, @Nullable Path<?> path) { |
|
|
|
|
return converter.toDBRef(constant, getPropertyForPotentialDbRef(path)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -135,7 +135,7 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
@@ -135,7 +135,7 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
|
|
|
|
|
|
|
|
|
|
MongoPersistentProperty property = getPropertyFor(path); |
|
|
|
|
|
|
|
|
|
return property.isIdProperty() ? key.replaceAll("." + ID_KEY + "$", "") : key; |
|
|
|
|
return property != null && property.isIdProperty() ? key.replaceAll("." + ID_KEY + "$", "") : key; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -144,8 +144,14 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
@@ -144,8 +144,14 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
|
|
|
|
|
return propertyFor == null ? super.isId(arg) : propertyFor.isIdProperty(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Nullable |
|
|
|
|
protected Object convert(@Nullable Path<?> path, @Nullable Constant<?> constant) { |
|
|
|
|
|
|
|
|
|
if (constant == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!isReference(path)) { |
|
|
|
|
|
|
|
|
|
MongoPersistentProperty property = getPropertyFor(path); |
|
|
|
|
@ -166,6 +172,7 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
@@ -166,6 +172,7 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
|
|
|
|
|
|
|
|
|
|
MongoPersistentProperty property = getPropertyFor(path); |
|
|
|
|
|
|
|
|
|
if (property != null) { |
|
|
|
|
if (property.isDocumentReference()) { |
|
|
|
|
return converter.toDocumentPointer(constant.getConstant(), property).getPointer(); |
|
|
|
|
} |
|
|
|
|
@ -178,6 +185,7 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
@@ -178,6 +185,7 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
|
|
|
|
|
} |
|
|
|
|
return asReference(constant.getConstant(), path.getMetadata().getParent()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return asReference(constant.getConstant(), path); |
|
|
|
|
} |
|
|
|
|
@ -203,7 +211,8 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
@@ -203,7 +211,8 @@ class SpringDataMongodbSerializer extends MongodbDocumentSerializer {
|
|
|
|
|
* @param path |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private MongoPersistentProperty getPropertyForPotentialDbRef(Path<?> path) { |
|
|
|
|
@Nullable |
|
|
|
|
private MongoPersistentProperty getPropertyForPotentialDbRef(@Nullable Path<?> path) { |
|
|
|
|
|
|
|
|
|
if (path == null) { |
|
|
|
|
return null; |
|
|
|
|
|