java.lang.ArrayIndexOutOfBoundsException: Index 48 out of bounds for length 4
package med.vol.api.controller;
import med.vol.api.medico.DadosCadastrosMedicos;
import med.vol.api.medico.DadosListagemMedicos;
import med.vol.api.medico.Medico;
import med.vol.api.medico.MedicoRepository;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.transaction.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
@RestController
@RequestMapping("/medicos")
public class MedicoController {
@Autowired
private MedicoRepository repository;
@PostMapping
@Transactional
public void cadastrar (@RequestBody DadosCadastrosMedicos dados) {
repository.save(new Medico(dados));
}
@GetMapping
public List<DadosListagemMedicos> listar() {
return repository.findAll().stream().map(DadosListagemMedicos::new).toList();
}
}
medico controller
package med.vol.api.controller;
import med.vol.api.medico.DadosCadastrosMedicos;
import med.vol.api.medico.DadosListagemMedicos;
import med.vol.api.medico.Medico;
import med.vol.api.medico.MedicoRepository;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.transaction.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
@RestController
@RequestMapping("/medicos")
public class MedicoController {
@Autowired
private MedicoRepository repository;
@PostMapping
@Transactional
public void cadastrar (@RequestBody DadosCadastrosMedicos dados) {
repository.save(new Medico(dados));
}
@GetMapping
public List<DadosListagemMedicos> listar() {
return repository.findAll().stream().map(DadosListagemMedicos::new).toList();
}
}
classe medico