Hello,--i'am trying to make a bulk insert with java objects. We are using the "@Version" and "@Id" annotation. Here is my code to it:public <E extends BasicEntity> void persist(List<E> entities) throws GeoJsonException {if (entities != null && !entities.isEmpty()) {String collectionName = entities.get(0).getClass().getAnnotation(Entity.class).value();BulkWriteOperation bulkWrite = mongoDatastore.getDB().getCollection(collectionName).initializeUnorderedBulkOperation();List<E> savedEntities = new ArrayList<>(entities.size());for (E ee : entities) {DBObject dbObject = morphia.toDBObject(ee);bulkWrite.insert(dbObject);savedEntities.add((E) morphia.fromDBObject(ee.getClass(), dbObject));}try {bulkWrite.execute();} catch (WriteConcernException e) {handleWriteConcernExcpetion(e);}entities.clear(); // we have to do it "pass-by-reference-value" :(entities.addAll(savedEntities);}}
If I execute the code i got a "Modification" exception. However if we delete the "@Version" annotation everything themes to work. Is there a way to insert the Java Object directly (without using "morphia.toDBObject") ?Regards, Andy
You received this message because you are subscribed to the Google Groups "Morphia" group.
To unsubscribe from this group and stop receiving emails from it, send an email to morphia+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Damn haven't seen it. Thanks :)
--