I am using the debugger in IntelliJ and right before the point of returning the result, the array is perfectly fine, as you can see here
But for some reason, the response in the browser looks like this
I don't understand why the fields are invisible.
This is what my 2 models look like:
Municipality:
@Entity
public class Municipality {
@Id
@JsonIgnore
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;
String name;
}
Prediction
@Entity
public class Prediction {
@Id
@JsonIgnore
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;
LocalDateTime tsPredictionMade;
LocalDateTime tsPredictionFor;
float pm10;
float pm25;
@ManyToOne
@OnDelete(action = OnDeleteAction.CASCADE)
Municipality municipality;
}
And this is my controller:
@RestController
@RequestMapping("/predict")
public class PredictionController {
private MunicipalityService municipalityService;
private PredictionService predictionService;
@Autowired
public PredictionController(MunicipalityService municipalityService, PredictionService predictionService) {
this.municipalityService = municipalityService;
this.predictionService = predictionService;
}
@GetMapping
public List<Municipality> getPredictions(){
List<Municipality> result = municipalityService.getPredictions();
return result;
}
@GetMapping("/{municipality}")
public List<Prediction> getPredictionsForMunicipality(@PathVariable("municipality") String name){
List<Prediction> result = predictionService.getPredictions(name);
return result;
}
}
The rest of the app (service and persistence layer) is pretty standard.
What is the reason for this?