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  see example here 
- Look under Oracle section on how to use database specific sequences  or "Sequence Native Query" at 
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?
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);
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.
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.