Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 312903

Summary: Support CDOQuery.getResult(CDOID.class) without resolving CDOIDs to EObjects
Product: [Modeling] EMF Reporter: Victor Roldan Betancort <vroldanbet>
Component: cdo.coreAssignee: Victor Roldan Betancort <vroldanbet>
Status: CLOSED WORKSFORME QA Contact: Eike Stepper <stepper>
Severity: enhancement    
Priority: P3 CC: stepper
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Victor Roldan Betancort CLA 2010-05-14 09:43:51 EDT
While performing a custom query which is supposed to return CDOIDs, I get the actual objects while iterating in the returning result List, instead of the CDOIDs I asked for.
Comment 1 Victor Roldan Betancort CLA 2010-06-07 06:13:41 EDT
It appears QueryResultList is just introduced to resolve CDOID as CDOObject. I think this kind of automatic resolving shall be done by the client.
However, this could break already existing queries that return CDOID, but the client do get the actual CDOObjects instead. This is the case of ResourceQuery. Other clients that have developed custom queries could experience the same problem.

The easy fix would be changing:

  @Override
  public List<T> asList()
  {
    List<Object> result = new ArrayList<Object>();
    while (super.hasNext())
    {
      result.add(super.next());
    }

    return new QueryResultList(result);
  }
  
to:

  @Override
  public List<T> asList()
  {
    List<T> result = new ArrayList<T>();
    while (super.hasNext())
    {
      result.add(super.next());
    }

    return result;
  }
  
I suggest we change this before there are more queries and more clients relying on the current semantics. Eike, what do you think?
Comment 2 Eike Stepper CLA 2010-06-29 04:50:57 EDT
Rebasing all outstanding enhancements requests to version 4.0
Comment 3 Eike Stepper CLA 2010-07-26 04:13:28 EDT
(In reply to comment #1)
> It appears QueryResultList is just introduced to resolve CDOID as CDOObject. I
> think this kind of automatic resolving shall be done by the client.

Generally? Why do you think that?
Comment 4 Victor Roldan Betancort CLA 2011-01-28 10:59:36 EST
lets talk about this bug again :P 
Well, probably most of the time people would like to get EObject. Granted, what happens when someone asks for CDOIDs? wont be possible.
Comment 5 Eike Stepper CLA 2011-01-29 02:01:45 EST
According to CDOQueryImpl.createQueryResult(Class<T>) the following should already work:

   List<CDOID> result = query.getResult(CDOID.class);

Please reopen if that does not work for you.
Comment 6 Victor Roldan Betancort CLA 2011-01-29 05:46:01 EST
Ok, I'll check it. It may have changed for 4.0 at some point and I didnt notice.
Comment 7 Eike Stepper CLA 2011-01-29 07:22:21 EST
The history says it's there for ages :P