public Key<T> save(T entity, WriteConcern wc) { return ds.save(entity, wc); }
public Key<T> save(T entity) { return ds.save(entity); }
@PrePersist void prePersist() { if (myLongId == null) { String collName = ds.getCollection(getClass()).getName(); Query<StoredId> q = ds.find(StoredId.class, "_id", collName); UpdateOperations<StoredId> uOps = ds.createUpdateOperations(StoredId.class).inc("value"); StoredId newId = ds.findAndModify(q, uOps); if (newId == null) { newId = new StoredId(collName); ds.save(newId); } myLongId = newId.getValue(); } }