-
1. Re: Modelling a Json entitty with array of "details"
dieman.one Jun 4, 2019 9:31 AM (in response to dieman.one)1 of 1 people found this helpfulI am thinking that my trouble was caused by the fact that one of my bean properties was called 'time', which Teiid did not like very much (perhaps a reserved word?)
-
2. Re: Modelling a Json entitty with array of "details"
rareddy Jun 4, 2019 10:28 AM (in response to dieman.one)I know there is support for List, but "List of Lists" I need to check to see if that support there, it needs to map to multi-dimensional array in Teiid.
-
3. Re: Modelling a Json entitty with array of "details"
rareddy Jun 4, 2019 10:30 AM (in response to dieman.one)1 of 1 people found this helpfulYes, "time" is a reserved word in the SQL/DDL. What was the error? Maybe I can update the error message to be clear?
-
4. Re: Modelling a Json entitty with array of "details"
dieman.one Jun 4, 2019 10:51 AM (in response to rareddy)Hi,
The error message is:
Caused by: org.teiid.api.exception.query.QueryParserException: TEIID31100 Parsing error: Encountered "records_total long, [*]time[*] long )" at line 14, column 156.
Was expecting: id
at org.teiid.query.parser.QueryParser.convertParserException(QueryParser.java:249)
It does highlight *time* with asterisks, but meaning of the error is pretty cryptic.
Thanks for getting back on this. I was able to figure out that problem with time, but still struggling with modelling the Json structure with embedded array, like in my original post:
{
"recordsFiltered": 18086,
"data": [
[1, "RESULT1", ""],
[2, "RESULT2", ""],
],
"query": "QUERY",
"hasMore": false,
"time": 553,
"draw": 0,
"recordsTotal": 18086
}
How should I model that "data" array inside my json? Variants I can think of:
- List<List<String>>
- Map<Integer, List<String>>
- POJO with one Inter, two Strings
- Another entity (JsonTable) plus many-to-one relation, (NOTE: there is an obvious problem with this approach - there is no foreign key to join on).
None of these seems to work. You mentioned a multi-dementional array, could you please provide exact syntax?
Would highly appreciate help.
Another thing I am struggling with passing parameters to my REST web service (I created a separate thread - (How to send the URI parameters to the REST web service via Teiid Spring Boot? )
Thanks,
D.
-
5. Re: Modelling a Json entitty with array of "details"
shawkins Jun 4, 2019 11:01 AM (in response to dieman.one)Yes, time is a reserved word: BNF for SQL Grammar · GitBook
It appears that the sql generation logic in JsonTableView does not account name quoting. Can you log an issue for that?
-
6. Re: Modelling a Json entitty with array of "details"
dieman.one Jun 4, 2019 11:14 AM (in response to shawkins)OK, could you please send me a link for this please? Never done this before.
-
7. Re: Modelling a Json entitty with array of "details"
dieman.one Jun 4, 2019 12:11 PM (in response to shawkins)As I reported on another thread, there is an issue creation issue.
SUMMARY: REST Web service integration: how to map nested structures?
DESCRIPTION:
Please describe how in Java Spring Boot Teiid one should model json with a nested structure. Example:
{
"recordsFiltered": 18086,
"data": [
[1, "RESULT1", ""],
[2, "RESULT2", ""],
],
"query": "QUERY",
"hasMore": false,
"time": 553,
"draw": 0,
"recordsTotal": 18086
}
What Java class should be used to represent array "data" so that Teiid can correctly transform queries into REST web service calls.
-
8. Re: Modelling a Json entitty with array of "details"
rareddy Jun 4, 2019 1:01 PM (in response to dieman.one)We do not support the mixed type arrays as in [integer, string, ..] they need to be a single simple type, for the mixed one like above you can try "List<Object>" but note any of SQL operations you can do on a specific data type you will lose that. for ex: using a function like `concat` etc.
-
9. Re: Modelling a Json entitty with array of "details"
dieman.one Jun 5, 2019 6:34 AM (in response to rareddy)Just tried out your recommendation: List<Object>. This causes the following error at application startup:
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)
Just for the fun of I also tried out the following :
@ElementCollection(targetClass = String.class)
private List<Object> data;
Then application starts normally, but the any query I throw at that bean causes another error
2019-06-05 12:32:41 WARN org.teiid.PROCESSOR - TEIID30020 Processing exception for request asKDfGQAeWrK.1 'Group does not exist: arthor_search_result_data AS data0_'. Originally QueryResolverException ResolverUtil.java:936.
org.teiid.api.exception.query.QueryResolverException: Group does not exist: arthor_search_result_data AS data0_
at org.teiid.query.resolver.util.ResolverUtil.handleUnresolvedGroup(ResolverUtil.java:936)
which is perhaps expected - it can't cast an integer to a String..
So it looks like there is no way for me to connect to my web service as is? That web service is a part of a commercial product and changing returned json is not an optio unfortunately...
-
10. Re: Modelling a Json entitty with array of "details"
rareddy Jun 11, 2019 7:09 PM (in response to dieman.one) -
11. Re: Modelling a Json entitty with array of "details"
rareddy Jun 13, 2019 11:23 AM (in response to rareddy)It should be fixed on the master branch right now, will be available from 1.2.0 release.
-
12. Re: Modelling a Json entitty with array of "details"
dieman.one Jun 14, 2019 6:15 AM (in response to rareddy)Hi, thanks for that.
When do you think R 1.2.0 will be available?
-
13. Re: Modelling a Json entitty with array of "details"
rareddy Jun 14, 2019 6:49 AM (in response to dieman.one)July 25th. 2019 is the target date. But you can download the master branch and compile and try out and let me know if you see any issues.