Converter not working with datanucleus-mongodb


qquantum@...
 

When persisting this model with datanucleus-mongodb 

@PersistenceCapable
public class Room implements Serializable {
  @PrimaryKey
  @Persistent(valueStrategy= IdGeneratorStrategy.IDENTITY)
  private String uid;
  private List<Availability> availabilities;
}


This Room model is stored as this document:

{

  "_id": {

    "$oid": "5fe619bde06a02dd8d35a93d"

  },

  "roomName": "Sample Room Name",

  "isPublished": false,

  "availabilities": [

    "5fe619bde06a02dd8d35a93e[OID]com.mycompany.models.Availability",

    "5fe619bde06a02dd8d35a93f[OID]com.mycompany.models.Availability"

  ]

}

Is it normal that the array items is stored like this? It does not look like a normal MongoDB document. 

The Availability model:

@PersistenceCapable
public class Availability implements Serializable {

  private String day;
  @Convert(LocalTimeConverter.class)
  private String opens;
  @Convert(LocalTimeConverter.class)
  private String closes;
}

And the Availability as such: 

{

  "_id": {

    "$oid": "5fe619bde06a02dd8d35a93e"

  },

  "opens": "07:00",

  "day": "SUNDAY",

  "closes": "11:00"

}

Although having a converter:

public class LocalTimeConverter implements AttributeConverter<String, Long> {
@Override
public Long convertToDatastore(String value) {
LocalTime localTime = LocalTime.parse(value);
return localTime.getLong(ChronoField.NANO_OF_DAY);
}

@Override
public String convertToAttribute(Long value) {
LocalTime localTime = LocalTime.ofNanoOfDay(value);
return localTime.toString();
}
}

I've tried debugging this, and from what I find, the converter is not even called despite annotated properly. 

Join main@datanucleus.groups.io to automatically receive all group messages.