@@ -205,6 +205,11 @@ List<Person> allPersons = Person.listAll();
205205ObjectId personId = new ObjectId(idAsString);
206206person = Person.findById(personId);
207207
208+ // finding a specific persons by their ID
209+ ObjectId personId1 = new ObjectId(id1AsString);
210+ ObjectId personId2 = new ObjectId(id2AsString);
211+ List<Person> person = Person.findByIds(List.of(personId1, personId2);
212+
208213// finding a specific person by ID via an Optional
209214Optional<Person> optional = Person.findByIdOptional(personId);
210215person = optional.orElseThrow(() -> new NotFoundException());
@@ -373,6 +378,11 @@ List<Person> allPersons = personRepository.listAll();
373378ObjectId personId = new ObjectId(idAsString);
374379person = personRepository.findById(personId);
375380
381+ // finding a specific persons by their ID
382+ ObjectId personId1 = new ObjectId(id1AsString);
383+ ObjectId personId2 = new ObjectId(id2AsString);
384+ List<Person> person = personRepository.findByIds(List.of(personId1, personId2);
385+
376386// finding a specific person by ID via an Optional
377387Optional<Person> optional = personRepository.findByIdOptional(personId);
378388person = optional.orElseThrow(() -> new NotFoundException());
@@ -863,7 +873,7 @@ data class Person (
863873
864874[IMPORTANT]
865875====
866- Unlike the @BsonCreator approach, `val` cannot be used here. Properties must be defined as `var`, otherwise, the system creates an object with
876+ Unlike the @BsonCreator approach, `val` cannot be used here. Properties must be defined as `var`, otherwise, the system creates an object with
867877`null` values for every property.
868878====
869879
@@ -935,6 +945,11 @@ Uni<List<ReactivePerson>> allPersons = ReactivePerson.listAll();
935945ObjectId personId = new ObjectId(idAsString);
936946Uni<ReactivePerson> personById = ReactivePerson.findById(personId);
937947
948+ // finding a specific persons by their ID
949+ ObjectId personId1 = new ObjectId(id1AsString);
950+ ObjectId personId2 = new ObjectId(id2AsString);
951+ Uni<List<Person>> person = ReactivePerson.findByIds(List.of(personId1, personId2);
952+
938953// finding a specific person by ID via an Optional
939954Uni<Optional<ReactivePerson>> optional = ReactivePerson.findByIdOptional(personId);
940955personById = optional.map(o -> o.orElseThrow(() -> new NotFoundException()));
0 commit comments