Hibernate mapping json to dto?

Viewed 88

I use Hibernate and I have a sql

SELECT category, 
 json_agg(json_build_object('id', id, 'name', name)) as role 
FROM table 
GROUP BY category;

postgres answer:

category | CAR
role     | [{"id" : 8, "name" : "BMW"}]

My dto java class:

public interface System  {
  String getCategory();
  List<Role> getRole();
}

public interface Role {
    Long getId();
   String getName();
}

I have a custom Query, when I call it from the controller, an error is thrown.

        @Query(value = "SELECT category, 
         json_agg(json_build_object('id', id, 'name', name)) as role 
        FROM table 
        GROUP BY category;", nativeQuery = true)
Collection<System> getSystem();

Error: org.hibernate.MappingException: No Dialect mapping for JDBC type: 1111

Please tell me how to make a mapping?

0 Answers
Related