I have this model class :
@Data
@Document(collection = "ndvtype")
public class NdvType {
@Id
private String id;
@Field
private String label;
@Field
private String typeProcessor;
@Field
private String description;
@Field
private String language;
}
I have these entries in my mongoDB (just one example among 476 entries, but they are all set the same way in my mongoDB) :
{
"_id": {
"$oid": "5f1ad9ae3845379e90539f18"
},
"label ": "ASM",
"typeProcessor": "ASMBNNNN",
"description": "Pgm ASSEMBLEUR Batch",
"language": "Assembleur"
}
My method looks like this :
public List<String> getAllNdvTypes () {
Iterable<NdvType> ndvTypesList = ndvTypeRepository.findAll();
List<NdvType> labelList = new ArrayList<>();
ndvTypesList.iterator().forEachRemaining(labelList::add);
return labelList.stream().map(NdvType::getLabel).distinct().collect(Collectors.toList());
}
Despite the fact that all my label fields are set in my database, the label is null after the findAll() (the other attributes are fetched properly by the findAll).
For example, if I change this line :
return labelList.stream().map(NdvType::getLabel).distinct().collect(Collectors.toList());
With this :
return labelList.stream().map(NdvType::getLanguage).distinct().collect(Collectors.toList());
It works.
I didn't find any problem/solution like this on stack overflow (or I didn't look well enough).
Anyone for that matter please?
Thank you in advance.