0

I am trying to use JPA to select a column of jsonb data type from a table, an i am having issues achieving that, but i can select others column that are not of the data type jsonb.

Here is the content of entity class

@EqualsAndHashCode(callSuper = true)
@Data
@Entity(name = "Assessment")
@Table(name = "assessment")
@TypeDefs({
    @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
})
@AllArgsConstructor
@NoArgsConstructor

public class Assessment extends ModelWithUUID {

  @Column(name = "session_id")
  private Integer sessionId;

  @Column(name = "section_id")
  private Integer sectionId;

  @Column(name = "subject_id")
  private Integer subjectId;

  @Column(name = "assessment", columnDefinition = "jsonb")
  @Type(type = "jsonb")
  private List assessment;

}

Here is my repository

@Repository
public interface AssessmentRepository extends 
JpaRepository<Assessment, UUID> {

@Query(value = "select assessment from 
       assessment where subject_id = 8 ", nativeQuery = true)
List<Object> findAssessmentsBySubjectId();

} 

And my controller looks like this

ResponseBody
@GetMapping("/subject/assessment")
public List<Object> getAssessment(){

    return assessmentRepository.findAssessmentsBySubjectId();
}

Here is the error i am getting

"timestamp": "2019-08-22T10:25:08.507+0000",
"status": 500,
"error": "Internal Server Error",
"message": "No Dialect mapping for JDBC type: 1111; nested exception 
is org.hibernate.MappingException: No Dialect mapping for JDBC type: 
1111",
"trace": "org.springframework.orm.jpa.JpaSystemException: No Dialect 
mapping for JDBC type: 1111; nested exception is 
org.hibernate.MappingException: No Dialect mapping for JDBC type: 
1111\n\tat 
Anana Aristotle
  • 344
  • 4
  • 12

1 Answers1

0

You may also define class for jsonb deserializing, for example

@Column(name = "assessment")
  @Type(type = "jsonb")
  private Assessment assessment;
begemoth
  • 321
  • 3
  • 10
  • Please can you throw light on this, because i have use this in my entity @TypeDefs({ @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class) }) – Anana Aristotle Aug 22 '19 at 17:00