@Document("scenarios")
public class Scenario {
@Id
private String id;
@Indexed(unique = true)
private String name;
private String description;
@JsonSerialize(using = PlatformSerializer.class)
private final List<Platform> platforms;
// getters and setters not shown
}
public class Platform {
private final PlatformData platformData;
@JsonSerialize(using = RowSerializer.class)
private final List<Row> rows;
// getters and setters not shown
}
@Repository
public interface ScenarioRepository extends MongoRepository<Scenario, String> {
Scenario findByName(String name);
}
The scenarios collection in the database contains embedded Platform objects in each document. And the Platform objects contain embedded Row objects. I can successfully get the Scenario object from the database using the findByName method in ScenarioRepository. The name and description values are correct. However, the platforms List is empty. I seem to recall that containers require an annotation in the POJO. Though the Scenario object was correctly saved to the database using this same code. What am I missing? Thanks!