Closed spring-projects-issues closed 6 years ago
John Blum commented
The workaround to this bug is to either 1) forgo using the SDG @EnableIndexing
configuration annotation and resort to explicit Spring bean definitions for Indexes, like so...
@Bean
@DependsOn("Customers")
public IndexFactoryBean customersNameIndex(GemFireCache gemfireCache) {
IndexFactoryBean customerNameIndex = new IndexFactoryBean();
customerNameIndex.setCache(gemfireCache);
customerNameIndex.setName("CustomersNameIdx");
customerNameIndex.setExpression("name");
customerNameIndex.setFrom("/Customers");
return customerNameIndex;
}
2) Alternatively, a user can drop the explicit Spring Data @Id
annotation on the application domain object identifier field or property as well as to explicitly call out the from
clause on any @Indexed
application domain object field or property, like so...
@Region("Customers")
class Customer {
Long id;
@Indexed(from = "/Customers")
String name;
...
}
It is more than likely a bug in Apache Geode that it does not recognize the Region name (i.e. "Customers") and you must explicitly specify the Region "path" in the "from clause" of the Index definition.
Fortunately, SDG properly identifies the "identifier" field or property of your application domain objects without explicitly marking the field or property with the Spring Data org.springframework.data.annotation.Id
providing the identifier is named "id", or the domain object JavaBean property is "getId()
" and "setId(..)
", respectively.
John Blum opened DATAGEODE-68 and commented
When defining Indexes via SDG mapping annotations on application domain object properties/fields without an explicit
from
clause specified, as in...Rather than...
The Spring container, and specifically Apache Geode fails to bootstrap and initialize properly, which is caused by the following Exception...
Affects: 2.0.2 (Kay SR2)
Referenced from: commits https://github.com/spring-projects/spring-data-gemfire/commit/c3b55ef2b7ca94f5d527248e58c9b6ed4f204806, https://github.com/spring-projects/spring-data-gemfire/commit/d9834794e538d73790efccd3ad22df4ed0b7ab99
Backported to: 2.0.3 (Kay SR3)