Adding default value for instant in Mongodb using MongoTemplate

52 Views Asked by At

I have a Java class

    @Document(collection = "vehicleCluster")
    public class VehicleCluster {
        private long imei;
        private int clusterId;
        private Instant insertTime;
        private List<Double> lats;
        private List<Double> longs;
        private List<Double> odos;
}

I wish to save the current time as "insertTime" when I save a document.I can, of course, set the value explicitly before inserting, but am unable to find a straightforward way to do this automatically using MongoTemplate.

Is there a simple annotation I can use get this done?

0

There are 0 best solutions below