JPA 无效流标头:32303138

Kpo*_*Kpo 7 java hibernate jpa spring-boot

我是 JPA / Hibernate 和 Spring Boot 的新手,现在我已经面临同样的错误超过 6 个小时,这让我发疯。

基本上,这一切都从我的控制器开始

@RestController
@RequestMapping("patientApi")
public class RestPatientController {

    public static final Logger LOGGER = LoggerFactory.getLogger(RestPatientController.class);

    @Autowired
    private PatientService patientService;

    [...]

    @RequestMapping(value = "/patient/prises_en_charge/{id}", method = RequestMethod.GET)
    public ResponseEntity<List<PriseEnCharge>> listAllPrisesEnChargeByPatient(@PathVariable("id") long id) {

        Patient currentPatient = patientService.findById(id);
        LOGGER.info("Récupération de toutes les prises en charges d'un patient avec id {}", currentPatient);
        List<PriseEnCharge> prisesEnCharge = patientService.findAllPrisesEnChargeByPatient(currentPatient);
        LOGGER.info("Liste de prises en charge {} ({} elements)", prisesEnCharge, prisesEnCharge.size());
        if (prisesEnCharge.isEmpty()) {
            LOGGER.debug("La liste des prises en charge est vide");
            return new ResponseEntity(HttpStatus.NO_CONTENT);
            // You many decide to return HttpStatus.NOT_FOUND

        }
        return new ResponseEntity<List<PriseEnCharge>>(prisesEnCharge, HttpStatus.OK);
    }

}
Run Code Online (Sandbox Code Playgroud)

在那里我捕获了我想要更多数据的元素的 ID。然后我在我的服务中调用 DAO

@Service("patientService")
@Transactional
public class PatientServiceImpl implements PatientService {

    @Autowired
    private PriseEnChargeDao priseEnChargeDao;

    [...]

    @Override
    public List<PriseEnCharge> findAllPrisesEnChargeByPatient(Patient patient) {
        return priseEnChargeDao.findPriseEnChargeByPatient(patient);
    }

}
Run Code Online (Sandbox Code Playgroud)

DAO 存在

@Repository
public interface PriseEnChargeDao extends JpaRepository<PriseEnCharge, Long> {

    @Query("from PriseEnCharge where id_patient = :patient")
    public List<PriseEnCharge> findPriseEnChargeByPatient(@Param("patient") Patient patient);

}
Run Code Online (Sandbox Code Playgroud)

无论我尝试什么,它都会不断抛出异常“java.io.StreamCorruptedException:无效流标头:32303138”。老实说我不知道​​了,我对那个案子有点绝望。

Ste*_*n C 8

我要在这里做一个猜测。如果32303138将 32 位字解释为十六进制并将其“解码”为 ASCII 字符,则会得到“2018”。在我看来,这就像某种日期字符串的前 4 个字符。

我的猜测是有些东西试图反序列化一个字符串,就好像它是一个对象流一样。这意味着数据库模式和休眠映射之间存在不匹配。