I am have the following class hierarchy.
When I save a Sensor instance with an event, the _class property is added.Code:public class Sensor { List<Event> events; } public abstract class Event { ... } public class PressureEvent extends Event { ... }
When I push an event onto the Sensor instance's event array the _class property is not added.Code:mongoTemplate.save(sensor, Sensor.class); { "_class" : "com.acme.Sensor", "events" : [ { "_class" : "com.acme.PressureEvent", ... } ] }
After an Event instance without a _class field is pushed onto the events array the sensor instance cannot be loaded due to the mapper not knowing the type of class.Code:mongoTemplate.updateFirst(new Query(Criteria.where("_id").is(new ObjectId(sensor.getId()))), new Update().push("events", event), Sensor.class); { "_class" : "com.acme.Sensor", "events" : [ { ... } ] }
Is this a bug or the intended behavior? Am I pushing onto the array improperly?Code:org.springframework.data.mapping.model.MappingInstantiationException: Could not instantiate bean class [com.acme.Event]: Is it an abstract class?; nested exception is java.lang.InstantiationException
I am using spring-data-mongodb-1.0.1.RELEASE.


Reply With Quote
