Skip to content

Commit 7a95cb6

Browse files
committed
DATAES-260 added missing test
1 parent 2718be7 commit 7a95cb6

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

src/test/java/org/springframework/data/elasticsearch/core/MappingBuilderTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,20 @@ public void shouldBuildMappingsForGeoPoint() throws IOException {
164164
assertThat(result, containsString("\"pointC\":{\"type\":\"geo_point\""));
165165
assertThat(result, containsString("\"pointD\":{\"type\":\"geo_point\""));
166166
}
167+
168+
/**
169+
* DATAES-260 - StacOverflow when two reverse relationship.
170+
*/
171+
@Test
172+
public void shouldHandleReverseRelationship() {
173+
//given
174+
elasticsearchTemplate.createIndex(User.class);
175+
elasticsearchTemplate.putMapping(User.class);
176+
elasticsearchTemplate.createIndex(Group.class);
177+
elasticsearchTemplate.putMapping(Group.class);
178+
//when
179+
180+
//then
181+
182+
}
167183
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.springframework.data.elasticsearch.entities;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
import org.springframework.data.annotation.Id;
7+
import org.springframework.data.elasticsearch.annotations.Document;
8+
import org.springframework.data.elasticsearch.annotations.Field;
9+
import org.springframework.data.elasticsearch.annotations.FieldType;
10+
11+
/**
12+
* Created by akonczak on 21/08/2016.
13+
*/
14+
15+
@Document(indexName = "groups", type = "group")
16+
public class Group {
17+
18+
@Id
19+
String id;
20+
21+
@Field(type = FieldType.Nested, ignoreFields ={"groups"})
22+
private Set<User> users = new HashSet<User>();
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.springframework.data.elasticsearch.entities;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
import org.springframework.data.annotation.Id;
7+
import org.springframework.data.elasticsearch.annotations.Document;
8+
import org.springframework.data.elasticsearch.annotations.Field;
9+
import org.springframework.data.elasticsearch.annotations.FieldType;
10+
11+
/**
12+
* Created by akonczak on 21/08/2016.
13+
*/
14+
15+
@Document(indexName = "users", type = "user")
16+
public class User {
17+
@Id
18+
private String id;
19+
20+
@Field(type= FieldType.Nested,ignoreFields={"users"})
21+
private Set<Group> groups = new HashSet<Group>();
22+
}

0 commit comments

Comments
 (0)