[CDO] SQL query results [message #662162] |
Tue, 29 March 2011 11:00  |
Eclipse User |
|
|
|
Hi,
I would like to run SQL queries on the CDO store and return several columns from the database. Unfortunately the CDOQuery returns only the first column when running the query.
Is there a reason why the SQLQueryHandler returns only the first column as a result of an SQL query even if not a CDO object query is run (SQLQueryHandler.CDO_OBJECT_QUERY is set to false)?
The code that returns the result in SQLQueryHandler.executeQuery() is the following:
if (objectQuery)
{
CDOID result = idHandler.getCDOID(resultSet, 1);
context.addResult(result);
}
else
{
Object result = resultSet.getObject(1);
context.addResult(result);
}
Would it make sense to change it to something like this?
if (objectQuery)
{
CDOID result = idHandler.getCDOID(resultSet, 1);
context.addResult(result);
}
else
{
int columnCount = resultSet.getMetaData().getColumnCount();
if (columnCount == 1)
{
Object result = resultSet.getObject(1);
context.addResult(result);
}
else
{
Object[] results = new Object[columnCount];
for (int i = 0; i < columnCount; i++)
{
results[i] = resultSet.getObject(i+1);
}
context.addResult(results);
}
}
If the query is not a CDOObject query, the client is probably interested in all of the queried fields.
Regards,
Szabolcs
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07339 seconds