java - JsonGenerationException: Null key for a Map not allowed in JSON (use a converting NullKeySerializer?) -


i'm trying add instance of class neo4j spring 4.0.0.release:

@nodeentity public class user {     @graphid     private long id;     @property     private uuid uniqueid = uuid.randomuuid();     @property     private string username;     @property     private string password;      // getters, setters, blah blah... } 

when exception:

error o.a.c.c.c.[.[.[.[dispatcherservlet] - servlet.service() servlet [dispatcherservlet] in context path [/pegboard] threw exception [request processing failed; nested exception org.neo4j.ogm.metadata.mappingexception: not create json due null key map not allowed in json (use converting nullkeyserializer?)] root cause com.fasterxml.jackson.core.jsongenerationexception: null key map not allowed in json (use converting nullkeyserializer?)     @ com.fasterxml.jackson.databind.ser.impl.failingserializer.serialize(failingserializer.java:35) ~[jackson-databind-2.6.5.jar:2.6.5]     @ com.fasterxml.jackson.databind.ser.std.mapserializer.serializefields(mapserializer.java:538) ~[jackson-databind-2.6.5.jar:2.6.5]     @ com.fasterxml.jackson.databind.ser.std.mapserializer.serialize(mapserializer.java:469) ~[jackson-databind-2.6.5.jar:2.6.5]     @ com.fasterxml.jackson.databind.ser.std.mapserializer.serialize(mapserializer.java:29) ~[jackson-databind-2.6.5.jar:2.6.5]     @ com.fasterxml.jackson.databind.ser.std.mapserializer.serializefields(mapserializer.java:561) ~[jackson-databind-2.6.5.jar:2.6.5]     @ com.fasterxml.jackson.databind.ser.std.mapserializer.serialize(mapserializer.java:469) ~[jackson-databind-2.6.5.jar:2.6.5]     @ com.fasterxml.jackson.databind.ser.std.mapserializer.serialize(mapserializer.java:29) ~[jackson-databind-2.6.5.jar:2.6.5]     @ com.fasterxml.jackson.databind.ser.beanpropertywriter.serializeasfield(beanpropertywriter.java:693) ~[jackson-databind-2.6.5.jar:2.6.5] ...more stack trace... 

what going on?

the uuid property causing error. because neo4j persist properties of primitive types + string fails mapped without use of converter. resolve create converter:

import org.neo4j.ogm.typeconversion.attributeconverter;  public class uuidconverter implements attributeconverter<uuid, string> {     @override     public string tographproperty(uuid uuid) {         return uuid.tostring();     }      @override     public uuid toentityattribute(string uuid) {         return uuid.fromstring(uuid);     } } 

then add convert annotation uuid property in user class:

import org.neo4j.ogm.annotation.typeconversion.convert;  ...  @property @convert(uuidconverter.class) private uuid uniqueid = uuid.randomuuid(); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -