Home > other >  I want to remove the association between two objects via @DeleteMapping. Java spring boot
I want to remove the association between two objects via @DeleteMapping. Java spring boot

Time:05-05

Unfortunately, I am unable to deal with the error. I have 2 id's of which the "mieszkanie" is owned by the "deweloper". Would anyone be able to help?

@DeleteMapping("/{deweloperId}/mieszkanie/{mId}")
  public ResponseEntity deleteMieszkanie(@PathVariable Long mId, @PathVariable Long deweloperId) {
      List<Mieszkanie> allMieszkania = mieszkanieRepository.findMieszkanieByDeweloperId(deweloperId);
      List<MieszkanieDto> result = allMieszkania.stream()
              .map(this::convertToDto)
              .collect(Collectors.toList());
      deweloperRepository.deleteById(mId);
      return new ResponseEntity(HttpStatus.NO_CONTENT);
  }

CodePudding user response:

What are you trying to do? If you have a field "DeweloperId" in Mieszkanie entity you only need delete Deweloper entity.

CodePudding user response:

two questions:

  1. provide an error message and/or stacktrace
  2. provide entities between which you have an association.
  • Related