DATAJDBC-374 - Polishing.

Clarified the effects of collections on nullable embedded entities.

Original pull request: #154.
This commit is contained in:
Jens Schauder
2019-05-22 12:46:15 +02:00
parent 55a3f9c372
commit ebe76a0c7f
2 changed files with 9 additions and 2 deletions

View File

@@ -378,11 +378,15 @@ public class BasicJdbcConverter extends BasicRelationalConverter implements Jdbc
ReadingContext<?> newContext = extendBy(property);
if(OnEmpty.USE_EMPTY.equals(property.findAnnotation(Embedded.class).onEmpty())) {
if(shouldCreateEmptyEmbeddedInstance(property) || newContext.hasInstanceValues(idValue)) {
return newContext.createInstanceInternal(idValue);
}
return newContext.hasInstanceValues(idValue) ? newContext.createInstanceInternal(idValue) : null;
return null;
}
private boolean shouldCreateEmptyEmbeddedInstance(RelationalPersistentProperty property) {
return OnEmpty.USE_EMPTY.equals(property.findAnnotation(Embedded.class).onEmpty());
}
private boolean hasInstanceValues(@Nullable Object idValue) {