DATAES-73 - NullPointerException while persist a Map as part of persistent entity

This commit is contained in:
Mohsin Husen
2014-03-23 19:06:47 +00:00
parent 07f5fab022
commit 5a78ba31f4
5 changed files with 80 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -119,13 +119,15 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
public void addPersistentProperty(ElasticsearchPersistentProperty property) {
super.addPersistentProperty(property);
Parent parent = property.getField().getAnnotation(Parent.class);
if (parent != null) {
Assert.isNull(this.parentIdProperty, "Only one field can hold a @Parent annotation");
Assert.isNull(this.parentType, "Only one field can hold a @Parent annotation");
Assert.isTrue(property.getType() == String.class, "Parent ID property should be String");
this.parentIdProperty = property;
this.parentType = parent.type();
if (property.getField() != null) {
Parent parent = property.getField().getAnnotation(Parent.class);
if (parent != null) {
Assert.isNull(this.parentIdProperty, "Only one field can hold a @Parent annotation");
Assert.isNull(this.parentType, "Only one field can hold a @Parent annotation");
Assert.isTrue(property.getType() == String.class, "Parent ID property should be String");
this.parentIdProperty = property;
this.parentType = parent.type();
}
}
if (property.isVersionProperty()) {

View File

@@ -55,7 +55,7 @@ public class SimpleElasticsearchPersistentProperty extends
@Override
public boolean isIdProperty() {
return super.isIdProperty() || SUPPORTED_ID_PROPERTY_NAMES.contains(getFieldName());
return super.isIdProperty() || field != null ? SUPPORTED_ID_PROPERTY_NAMES.contains(getFieldName()) : false;
}
@Override