Let's assume a simple User
class (with a public field just for the sample) like this:
public class User {
public UserId userId;
}
public class UserId {
public String value = "1"; //hardcoded for the example
}
When Spring has to demand a serialization in order to make a remote call involving a User
object, the UserId
field is well serialized to "1"
.
However, when I annotate the UserId
field with some Spring annotation, in my case @Indexed
from Spring-Data-Neo4j, I get this stack:`
RuntimeException: : org.codehaus.jackson.map.JsonMappingException: No serializer found for class com.model.user.UserId and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.HashMap["value"]) (JsonHelper.java:77)
[error] org.neo4j.rest.graphdb.util.JsonHelper.createJsonFrom(JsonHelper.java:77)
[error] org.neo4j.rest.graphdb.ExecutingRestRequest.post(ExecutingRestRequest.java:140)
[error] org.neo4j.rest.graphdb.ExecutingRestAPI.addToIndex(ExecutingRestAPI.java:410)
[error] org.neo4j.rest.graphdb.RestAPIFacade.addToIndex(RestAPIFacade.java:166)
[error] org.neo4j.rest.graphdb.index.RestIndex.add(RestIndex.java:60)
Annotation seems to cause this to break. Is there a good reason to this? Is there a way to serialize it although an annotation is present?