@@ -1141,8 +1141,9 @@ <S, T> T findAndReplace(Query query, S replacement, FindAndReplaceOptions option
1141
1141
* Insert is used to initially store the object into the database. To update an existing object use the save method.
1142
1142
*
1143
1143
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
1144
+ * @return the inserted object.
1144
1145
*/
1145
- void insert (Object objectToSave );
1146
+ < T > T insert (T objectToSave );
1146
1147
1147
1148
/**
1148
1149
* Insert the object into the specified collection.
@@ -1154,32 +1155,36 @@ <S, T> T findAndReplace(Query query, S replacement, FindAndReplaceOptions option
1154
1155
*
1155
1156
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
1156
1157
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
1158
+ * @return the inserted object.
1157
1159
*/
1158
- void insert (Object objectToSave , String collectionName );
1160
+ < T > T insert (T objectToSave , String collectionName );
1159
1161
1160
1162
/**
1161
1163
* Insert a Collection of objects into a collection in a single batch write to the database.
1162
1164
*
1163
1165
* @param batchToSave the batch of objects to save. Must not be {@literal null}.
1164
1166
* @param entityClass class that determines the collection to use. Must not be {@literal null}.
1167
+ * @return the inserted objects that.
1165
1168
*/
1166
- void insert (Collection <? extends Object > batchToSave , Class <?> entityClass );
1169
+ < T > Collection < T > insert (Collection <? extends T > batchToSave , Class <?> entityClass );
1167
1170
1168
1171
/**
1169
1172
* Insert a batch of objects into the specified collection in a single batch write to the database.
1170
1173
*
1171
1174
* @param batchToSave the list of objects to save. Must not be {@literal null}.
1172
1175
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
1176
+ * @return the inserted objects that.
1173
1177
*/
1174
- void insert (Collection <? extends Object > batchToSave , String collectionName );
1178
+ < T > Collection < T > insert (Collection <? extends T > batchToSave , String collectionName );
1175
1179
1176
1180
/**
1177
1181
* Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
1178
1182
* class.
1179
1183
*
1180
1184
* @param objectsToSave the list of objects to save. Must not be {@literal null}.
1185
+ * @return the inserted objects.
1181
1186
*/
1182
- void insertAll (Collection <? extends Object > objectsToSave );
1187
+ < T > Collection < T > insertAll (Collection <? extends T > objectsToSave );
1183
1188
1184
1189
/**
1185
1190
* Save the object to the collection for the entity type of the object to save. This will perform an insert if the
@@ -1195,8 +1200,9 @@ <S, T> T findAndReplace(Query query, S replacement, FindAndReplaceOptions option
1195
1200
* Conversion"</a> for more details.
1196
1201
*
1197
1202
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
1203
+ * @return the saved object.
1198
1204
*/
1199
- void save (Object objectToSave );
1205
+ < T > T save (T objectToSave );
1200
1206
1201
1207
/**
1202
1208
* Save the object to the specified collection. This will perform an insert if the object is not already present, that
@@ -1213,8 +1219,9 @@ <S, T> T findAndReplace(Query query, S replacement, FindAndReplaceOptions option
1213
1219
*
1214
1220
* @param objectToSave the object to store in the collection. Must not be {@literal null}.
1215
1221
* @param collectionName name of the collection to store the object in. Must not be {@literal null}.
1222
+ * @return the saved object.
1216
1223
*/
1217
- void save (Object objectToSave , String collectionName );
1224
+ < T > T save (T objectToSave , String collectionName );
1218
1225
1219
1226
/**
1220
1227
* Performs an upsert. If no document is found that matches the query, a new document is created and inserted by
0 commit comments