/** * Get the saved IDs. This may be useful for finding out the IDs that were generated by MongoDB if no IDs were * supplied. * * @return The saved IDs */ public List<K> getSavedIds() { if (dbObjects.length > 0 && dbObjects[0] instanceof JacksonDBObject) { throw new UnsupportedOperationException("Generated _id retrieval not supported when using stream serialization"); } List<K> ids = new ArrayList<K>(); for (int i = 0; i < dbObjects.length; i++) { ids.add((K) jacksonDBCollection.convertFromDbId(dbObjects[i].get("_id"))); } return ids; }
/** * Get the saved IDs. This may be useful for finding out the IDs that were generated by MongoDB if no IDs were * supplied. * * @return The saved IDs */ public K[] getSavedIds() { if (dbObjects.length > 0 && dbObjects[0] instanceof JacksonDBObject) { throw new UnsupportedOperationException("Generated _id retrieval not supported when using stream serialization"); } K[] ids = (K[]) new Object[dbObjects.length]; for (int i = 0; i < dbObjects.length; i++) { ids[i] = jacksonDBCollection.convertFromDbId(dbObjects[i].get("_id")); } return ids; }
/** * Get the saved ID. This may be useful for finding out the ID that was generated by MongoDB if no ID was supplied. * * @return The saved ID * @throws MongoException If no objects were saved */ public K getSavedId() { if (dbObjects.length == 0) { throw new MongoException("No objects to return"); } if (dbObjects[0] instanceof JacksonDBObject) { throw new UnsupportedOperationException("Generated _id retrieval not supported when using stream serialization"); } return jacksonDBCollection.convertFromDbId(dbObjects[0].get("_id")); }
/** * Get the saved ID. This may be useful for finding out the ID that was generated by MongoDB if no ID was supplied. * * @return The saved ID * @throws MongoException If no objects were saved */ public K getSavedId() { if (dbObjects.length == 0) { throw new MongoException("No objects to return"); } if (dbObjects[0] instanceof JacksonDBObject) { throw new UnsupportedOperationException("Generated _id retrieval not supported when using stream serialization"); } return jacksonDBCollection.convertFromDbId(dbObjects[0].get("_id")); }