Annotation Type JsonTable


  • @Target(TYPE)
    @Retention(RUNTIME)
    public @interface JsonTable
    Use this annotation on any Entity class, that defines the data from a JSON file or web resource.
    For Example if you have a JSON payload like
     
    [
       {
          "id":1,
          "FirstName":"John",
          "LastName":"Doe",
          "Age":20
       },
       {
          "id":2,
          "FirstName":"Susan",
          "LastName":"Webber",
          "Age":55
       },
       {
          "id":1,
          "FirstName":"Mike",
          "LastName":"Smith",
          "Age":34
       }
    ]
     
     
    You can parse and read the contents of this file into an entity by defining this annotation on a Entity class like
     
     @Entity
     @JsonTable(source=file, endpoint="/path/to/file.txt" rootIsArray=true)
     public class Person {
        @Id
        private int id;
    
        @Column(name="FirstName")
        private String firstName;
    
        @Column(name="LastName")
        private String lastName;
    
        @Column(name="Age")
        private int age;
        ...
     }
     
     
    Note: the getters and setter are omitted for brevity.
    For more information checkout XMLTABLE in Teiid.
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String endpoint
      On Class ONLY The endpoint where the document is located at.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean ordinal
      On Column ONLY, this defines the column as ordinal identity column.
      String root
      Root of the document where the parsing needs to start from.
      boolean rootIsArray
      JSON root content is array.
      String source
      Source name; If overriding the org.teiid.translator.ws.WsExecutionFactory bean then provide the name of the bean
    • Element Detail

      • endpoint

        String endpoint
        On Class ONLY The endpoint where the document is located at. If this is file resource then this field can be used to define name of the file. If this is REST based call, it can either define the endpoint URL or can refer to a bean name that returns Function <org.teiid.translator.ExecutionContext, byte[]> or Function <org.teiid.translator.ExecutionContext, String> or Function <org.teiid.translator.ExecutionContext, InputStream> Where byte[], String and InputStream are response from the REST call made.
        Returns:
        string - file/endpoint or name of the bean
      • source

        String source
        Source name; If overriding the org.teiid.translator.ws.WsExecutionFactory bean then provide the name of the bean
        Returns:
        string
        Default:
        "rest"
      • ordinal

        boolean ordinal
        On Column ONLY, this defines the column as ordinal identity column. The data type must be integer. A FOR ORDINALITY column is typed as integer and will return the 1-based item number as its value.
        Returns:
        boolean
        Default:
        false
      • root

        String root
        Root of the document where the parsing needs to start from.
        Returns:
        string
        Default:
        "/"
      • rootIsArray

        boolean rootIsArray
        JSON root content is array. ex: [{...}, {...}]
        Returns:
        boolean
        Default:
        false