Good I have a table personas
with a relation oneToMany
, and another table personemergencycontacts
, that is, a person can have many emergency contacts, the question is that in the modal
of contactos de emergencia
is not how to bring only that person's contacts, bring me all the records.
methods: {
getData() {
this.$axios.get('persons/' + this.person_id).then((response) => {
this.form.person = response.data;
});
this.$axios.get('personemergencycontacts' ).then((response) => {
this.allData = response.data;
this.loading = false;
});
},
Can I use this query to make a join with the id of personemergencycontact
? Effectively I use spring mvc
@GetMapping("/persons/{id}")
public ResponseEntity getPersonById(@PathVariable(value = "id") Long personId) {
try {
Person person = service.findById(personId);
if (person == null) {
LOGGER.warn("PersonController | Imposible obtener entidad, no existe registro con identificador: " + personId + ".");
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new responseMessage(HttpStatus.NOT_FOUND.value(), null, "No existe persona."));
}
LOGGER.info("PersonController | Identificador solicitado: " + personId + ".");
return ResponseEntity.ok().body(person);
} catch (Exception e) {
LOGGER.error(e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new responseMessage(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), getLocaleMessage("error.internal_error")));
}
}