use of org.odata4j.core.OEntity in project teiid by teiid.
the class ODataUpdateExecution method addAutoGeneretedKeys.
private void addAutoGeneretedKeys() {
OEntity entity = this.response.getResultsIter().next().getEntity();
Table table = this.visitor.getEnityTable();
int cols = table.getPrimaryKey().getColumns().size();
Class<?>[] columnDataTypes = new Class<?>[cols];
String[] columnNames = new String[cols];
// this is typically expected to be an int/long, but we'll be general here. we may eventual need the type logic off of the metadata importer
for (int i = 0; i < cols; i++) {
columnDataTypes[i] = table.getPrimaryKey().getColumns().get(i).getJavaType();
columnNames[i] = table.getPrimaryKey().getColumns().get(i).getName();
}
GeneratedKeys generatedKeys = this.executionContext.getCommandContext().returnGeneratedKeys(columnNames, columnDataTypes);
List<Object> vals = new ArrayList<Object>(columnDataTypes.length);
for (int i = 0; i < columnDataTypes.length; i++) {
OProperty<?> prop = entity.getProperty(columnNames[i]);
Object value = this.translator.retrieveValue(prop.getValue(), columnDataTypes[i]);
vals.add(value);
}
generatedKeys.addKey(vals);
}
Aggregations