13 Replies Latest reply on Jun 14, 2019 6:49 AM by Ramesh Reddy

    Modelling a Json entitty with array of "details"

    dmitri kov Newbie

      Dear Sirs,

       

      Perhaps one more novice question. I am still trying to get by Spring Boot/REST data source example work.

      The json return by my WS is this:

      {

          "recordsFiltered": 10,

          "data": [

              [

                  1,

                  "<String1>\t253857",

                  ""

              ],

              [

                  2,

                  "<String2>\t253859",

                  ""

              ],

          ],

          "query": "<String3>",

          "hasMore": true,

          "time": 0,

          "draw": 0,

          "recordsTotal": 10

      }

       

      It's a kind of master table with embedded array of "data" objects, each containing exactly 3 values

      Since there is no explicit join between "master" and "detail", I modeled it as one entitywith a collection property (Is this correct)?

      My bean:

      @Getter
      @Setter
      @NoArgsConstructor
      @AllArgsConstructor
      @JsonTable(endpoint="http://<...>", source="rest", root="/")

      @Entity
      public class ArthorSearchResult{

       

         @Id
        private String query;


        private Long time;
        private Long draw;
        private Long recordsFiltered;
        private Long recordsTotal;
        private Boolean hasMore;

      private List<List<String>> data;

       

      (getters and setter omitted/supplied by LOMBOK)
      }

       

      At start-up Spring throws this error:

       

      Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: arthor_search_result, for columns: [org.hibernate.mapping.Column(data)]

          at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:486)

       

      Could you please point out what I am doing wrong?

       

      Should I model the collection 'data' property:

      1) as in my example - a Java collection?

      2) As a collection of POJOs

      3) As a collection of another entity comprising the 3 fields

       

      Many thanks1

      Dmitry