use of com.yahoo.elide.datastores.aggregation.queryengines.sql.annotation.VersionQuery in project elide by yahoo.
the class SQLQueryEngine method getTableVersion.
@Override
public String getTableVersion(Table table, Transaction transaction) {
String tableVersion = null;
SQLTable sqlTable = (SQLTable) table;
Type<?> tableClass = metadataDictionary.getEntityClass(table.getName(), table.getVersion());
VersionQuery versionAnnotation = tableClass.getAnnotation(VersionQuery.class);
if (versionAnnotation != null) {
String versionQueryString = versionAnnotation.sql();
SqlTransaction sqlTransaction = (SqlTransaction) transaction;
ConnectionDetails details = sqlTable.getConnectionDetails();
DataSource dataSource = details.getDataSource();
NamedParamPreparedStatement stmt = sqlTransaction.initializeStatement(versionQueryString, dataSource);
tableVersion = CoerceUtil.coerce(runQuery(stmt, versionQueryString, SINGLE_RESULT_MAPPER), String.class);
}
return tableVersion;
}
Aggregations