-
1. Re: What is the best way to assign primary keys to views for OData
rareddy Mar 23, 2015 9:24 AM (in response to sanjeev.gour)2.2 Should not be an issue, this may be something source specific as you are suggesting. Can you provide more details on this? stack trace etc.
For automatic key generation you can use
- ROW_NUMBER [1] see example here [2]
- Look under Oracle section on how to use database specific sequences [3] or "Sequence Native Query" at [4]
[1] BNF for SQL Grammar - Teiid 8.11 (draft) - Project Documentation Editor
[3] https://docs.jboss.org/author/display/TEIID/JDBC+Translator
[4] DDL Metadata - Teiid 8.11 (draft) - Project Documentation Editor
-
2. Re: What is the best way to assign primary keys to views for OData
sanjeev.gour Mar 24, 2015 7:26 AM (in response to rareddy)The primary key already defined on this view was due to mistake I made in the view, I had mentioned two separate columns as primary key columns.
For the automatic key generation, the row_number seems Oracle specific, is there something that Teiid supports so that it can be done centrally?
-
3. Re: What is the best way to assign primary keys to views for OData
rareddy Mar 24, 2015 8:22 AM (in response to sanjeev.gour)ROW_NUMBER is also supported by Teiid, I gave relevant links above. See example here Integrate Amazon SimpleDB with Teiid
-
4. Re: What is the best way to assign primary keys to views for OData
sanjeev.gour Mar 24, 2015 8:46 AM (in response to rareddy)Thanks Ramesh, that should work for me, sorry, I misread your comment.
I am running into another issue now. I am generating the metadata dynamically and the primary keys as follows-
List<String> pKeyColumnNames = (List<String>) pKeysMap.get(objectName);
if(!pKeyColumnNames.isEmpty()){
metadataFactory.addPrimaryKey("primaryKey",pKeyColumnNames , objectTable);
}
When I query the data from Squirrel it works fine but when I access it through the REST url, it results in an error. There are two things to note-
- When I use the url http://localhost:8080/odata/VDB.1/objectName Teiid adds the ORDER BY clause with primary key columns which I don't want.
- The object has a lot of columns, so the column alias go into two digit like c_1, c_2...c_23.....and forms in incorrect query like the following-
SELECT ...from .. ORDER BY "c_0", "c_1", "c_2", "c_3", "c_2"3, "c_3"5 - If you notice the quotes are improper. This seems like a bug.
Thanks.
-
5. Re: What is the best way to assign primary keys to views for OData
shawkins Mar 24, 2015 9:19 AM (in response to sanjeev.gour)1) That behavior is effectively mandated by OData. It requires that results are given with a predictable ordering which is typically taken to be the primary key.
2) You'd have to log that as an issue. I don't recall the OData layer doing any particular string manipulation of the order by column names, so that seems odd.
-
6. Re: What is the best way to assign primary keys to views for OData
sanjeev.gour Mar 25, 2015 1:14 AM (in response to shawkins)Thanks Steve.
Opened as issue https://issues.jboss.org/browse/TEIID-3401.