1 Reply Latest reply on Jan 29, 2008 7:11 AM by Pete Muir

    Same ResultList as return value of an entityQuery

    Marc Nufer Newbie

      Hi all

      I just came across a strange "feature". I'm not sure if I'm missing something but think it could help others struggling with the same kind of problem.
      My setup is the following:

      - One EntityQuery
      - One example object used in the query
      - One method executing the query multiple times

      In my method, I call the query with some different example objects and store the results in different Lists to merge them in certain circumstances into one of them. The result was not as expected: I had objects in my list I haven't copied into, so the question was: "How did they come in my list?" After debugging the problem and it's solution was clear: The EntityQuery method getResultList() works just with one single List instance and therefore all resultLists were merged together. The solution was to instantiate each time a new list and copy the ResultList into it.

      From my point of view, the EntityQuery should return for each method call a new List but I'm open for arguments against.