JPA无效的流标头:32303138 [英] JPA invalid stream header: 32303138

查看:74
本文介绍了JPA无效的流标头:32303138的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是使用Spring Boot的JPA/Hibernate的新手,并且已经遇到了超过6个小时的错误,这使我发疯.

I'm new with JPA / Hibernate with Spring Boot and I've been facing the same error for over 6hours now, this is driving me crazy.

基本上,所有操作都从此处的我的控制器开始

Basically, it all start at my Controller here

@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);
    }

}

在其中捕获要获取更多数据的元素的ID.然后,我在服务范围内致电DAO

where I catch the ID of the element I want more data for. I then call the DAO within my service

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

    @Autowired
    private PriseEnChargeDao priseEnChargeDao;

    [...]

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

}

DAO正在

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

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

}

无论我尝试了什么,它始终抛出异常"java.io.StreamCorruptedException:无效的流头:32303138".我真的不知道了,我对此感到绝望.

No matter what I tried It keeps throwing exception "java.io.StreamCorruptedException: invalid stream header: 32303138". I honnestly don't know anymore, I'm kinda despaired on that case.

推荐答案

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

I am going to make a guess here. If you interpret 32303138 as a 32 bit word in hexadecimal and "decode" it as ASCII characters, you get "2018". That looks to me like the first 4 characters of a date string of some kind.

我的猜测是 something 正在尝试对字符串进行反序列化,就好像它是对象流一样.这意味着数据库架构和休眠映射之间不匹配.

My guess is that something is attempting to deserialize a character string as if it was an object stream. That implies that there is a mismatch between the database schema and the hibernate mappings.

这篇关于JPA无效的流标头:32303138的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆