|
Re: [CDO] SQL query results [message #662253 is a reply to message #662162] |
Tue, 29 March 2011 21:21 |
|
Hi Szabolcs,
I guess we just didn't do it because nobody asked for it in the past. Maybe because the transport protocol is not prepared to deliver arrays of arbitrary objects. Seems you've already played with the code, are you willing to open a bugzilla and attach a patch including some test cases? I'll be back from California next week and could review it then...
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Am 29.03.2011 08:00, schrieb Szabolcs Bardy:
> 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
>
>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Powered by
FUDForum. Page generated in 0.03763 seconds