I'm not sure if this is possible by default mapping Firebase data, but there is a possible workaround. First explain the errors you see:
com.google.firebase.database.DatabaseException: no serialization properties found in com.example.app.model.Office class
The Firebase converter looks for either public fields or fields with a name with the pattern getFoo / setFoo . So, on your class mapper does not see any properties.
java.lang.InstantiationException: unable to instantiate abstract class com.example.app.model.Office
This is what I think you will have problems getting around. In order for deserialization to work, your class must have an open constructor without arguments, which can display the translator through reflection ( newInstance() ). As far as I know, this is not how AutoValue works.
But do not lose hope! . According to this github issue , there is a way to make compatibility with Jackson and AutoValue using the @JsonCreator annotation. Therefore, you will need to use both Jackson and Firebase to do this work here.
Serialization:
// Convert to a Map<String,Object> using Jackson and then pass that to Firebase ObjectMapper mapper = new ObjectMapper(); Map<String, Object> map = mapper.convertValue(office, Map.class); databaseReference.setValue(map);
deserialization:
source share