javaspringhibernatejpaserialization

could not deserialize] with root cause java.io.EOFException: null


I have seen some questions on this subject but I have not got any valid solution for my case

I'm having an exception with jason serialization I have the following classes

when I do a GET Pacientes I have an exception of the serialization privilege type

2017-11-14 08:54:35.039  INFO 8724 --- [nio-8080-exec-1] o.h.e.internal.DefaultLoadEventListener  : HHH000327: Error performing load command : org.hibernate.type.SerializationException: could not deserialize
2017-11-14 08:54:35.047 ERROR 8724 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not deserialize; nested exception is org.hibernate.type.SerializationException: could not deserialize] with root cause

    java.io.EOFException: null
        at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source) ~[na:1.8.0_144]
        at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source) ~[na:1.8.0_144]
        at java.io.ObjectInputStream.readStreamHeader(Unknown Source) ~[na:1.8.0_144]
        at java.io.ObjectInputStream.<init>(Unknown Source) ~[na:1.8.0_144]
        at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:309) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
        at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:299) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
        at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:218) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]

I'm using framwork Spring boot with spring data jpa

class Paciente

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import digifred.model.global.Entidades;
import digifred.model.global.IdentidadesGenero;
import digifred.model.global.OrientacoesSexuais;
import digifred.model.global.Pessoas;


@Entity
@Table(name = "pacientes", schema = "sau")
public class Pacientes implements Serializable  {



    private static final long serialVersionUID = 5776384003601026304L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idPaciente")
    private Long idPaciente;


    @JoinColumn(name="id_entidade")
    @ManyToOne(cascade = CascadeType.ALL)
    private Entidades entidade;


    @Basic(optional = false)
    @JoinColumn(name="idPessoa")
    @ManyToOne(cascade = CascadeType.ALL)
    private Pessoas pessoa;


    @Column(name = "idResponsavel_familiar")
    private BigInteger responsavelFamiliar;


    @Column(name = "nomeResponsavel")
    private String nomeResponsavel;


    @Column(name = "cpfResponsavel")
    private String cpfResponsavel;


    @Column(name = "cnsResponsavel")
    private String cnsResponsavel;


    @Column(name = "flagAlergico")
    private Integer flagAlergico;


    @Column(name = "observacoesAlergias")
    private String observacoesAlergias;


    @Column(name = "microarea")
    private String microarea;


    @Column(name = "idDomicilio")
    private Long idDomicilio;


    @JoinColumn(name="idOrientacaoSexual")
    @ManyToOne
    private OrientacoesSexuais orientacaoSexual;


    @JoinColumn(name="idIdentidadeGenero", insertable=false, updatable=false)
    @ManyToOne
    private IdentidadesGenero identidadeGenero;


    @Basic(optional = false)
    @Column(name = "flag_ativo")
    private int flagAtivo;


    @JoinColumn(name="idArea")
    @ManyToOne
    private Areas area;


    @JoinColumn(name="idFamilia")
    @ManyToOne
    private Familias familia;

    public Pacientes() {
    }


 getters and setters
}

Solution

  • Looks like you're trying to deserialize an empty stream.