org.hibernate.type.SerializationException: could not deserialize error, using CriteriaBuilder API to read json field from postgreSQL

Viewed 291

In my postgreSQL table I have a column named details of type json. While reading it from the database using criteriabuilder api I am getting serialization error.

Field in the model class mapped to the postgreSQL database

Detail.java contains the below field

@Column(name = "details")
PGobject details;

DetailDTO.java contains the below field

@JsonProperty("app_details")
PGobject appDetails;
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<DetailDTO> criteriaQuery = criteriaBuilder.createQuery(DetailDTO.class);
Root<Detail> root = criteriaQuery.from(Detail.class);
criteriaQuery.select(root.get("details"));

List<DetailDTO> detailDTOS = entityManager.createQuery(criteriaQuery).getResultList();

Below error occurs during the execution of the getResultList() function

javax.persistence.PersistenceException: org.hibernate.type.SerializationException: could not deserialize
0 Answers
Related