I am doing an application in Symfony2 and using the doctrine mongodb odm bundle. I created a document with an id that has strategy=NONE, like (just a snippet):
use DoctrineODMMongoDBMappingAotations as MongoDB;
/**
* @MongoDBId(strategy="NONE")
* @var string
*/
private $id;
Later on while inserting, every time I specify the id before calling persist, upon checking the logs I find that an upsert was done instead of a batchInsert. After some googling, I ran into this link that confirmed to me that, this is in fact, the case by design.
My question therefore is: how can avoid the upsert from happening after I have specified the object's id?
Ps: I need this because with the upsert, doctrine mongodb odm will update in case it finds the id already there, yet I want it to see such as a duplicate and throw a MongoDuplicateKeyException.
