Sorry for very dumb question. I'm using Morphia 1.00. Have some entity:
@Entity("Vacancy")
public class Vacancy {
@Id
private ObjectId id;
@Version
long version;
private String title;
and some other fields, setter and getters. Trying to save identical instances:
Vacancy vacancy1 = new Vacancy();
vacancy1.setTitle("Dumm");
Vacancy vacancy2 = new Vacancy();
vacancy2.setTitle("Dumm");
vacancyDao.getDatastore().save(vacancy1);
vacancyDao.getDatastore().save(vacancy2);
As I know, mongoDb must execute upsert command(means "update if present; insert (a single document) if missing"). But instead of just updating the _id field, mongo saves new entity in the DB.