@Indexed(unique = true)
private String name;
allows me to store two entities with same name.
Added test for unique index fix. The test demonstrates how clean up has to be handled for unit tests, otherwise the indexes are not re-created if the collection is deleted.
The fix is not complete. In M2 the object is not saved; however it acts as if the record is saved. A new Object Id is generated and no exception is thrown. Expected is MongoException.DuplicateKey or that exception wrapped in a RuntimeException.
It seems the behavior you see is due to a corner case dealing with the repository subsystem creating a duplicate index. Would you mind opening a new ticket? We prefer new ones over reopened ones as this one is bound to the M2 milestone which was released already.