OpenJPA
  1. OpenJPA
  2. OPENJPA-787

slices query.getSingleResult is broken

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M2
    • Fix Version/s: 2.0.0-M2
    • Component/s: slice
    • Labels:
      None

      Description

      Pinaki Poddar wrote:
      > Query.getSingleResult() is badly broken (or, more precisely non-existent).
      > Currently, use the workaround for Query.getSingleResult() i.e.
      > Query.getResultList().get(0)

        Activity

        Hide
        Fernando Padilla added a comment -

        very simple patch. should fix this issue.

        — openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java (revision 721000)
        +++ openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java (working copy)
        @@ -147,10 +147,10 @@
        }
        boolean[] ascending = getAscending(q);
        boolean isAscending = ascending.length > 0;

        • boolean isUnique = q.getContext().isUnique();
          + boolean isAggregate = q.getContext().isAggregate();
          boolean hasRange = q.getContext().getEndRange() != Long.MAX_VALUE;
          ResultObjectProvider result = null;
        • if (isUnique) {
          + if (isAggregate) { result = new UniqueResultObjectProvider(tmp, q, getQueryExpressions()); }

          else if (isAscending) {

        But though it looks like it's working better. Now I'm hitting another bug, that it looks like somehow the old EnityManager/Broker is being reused across requests. I know this because it works fine for first request, but second request complains that the Broker is already closed. So I might be opening up a new bug for that.

        Show
        Fernando Padilla added a comment - very simple patch. should fix this issue. — openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java (revision 721000) +++ openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStoreQuery.java (working copy) @@ -147,10 +147,10 @@ } boolean[] ascending = getAscending(q); boolean isAscending = ascending.length > 0; boolean isUnique = q.getContext().isUnique(); + boolean isAggregate = q.getContext().isAggregate(); boolean hasRange = q.getContext().getEndRange() != Long.MAX_VALUE; ResultObjectProvider result = null; if (isUnique) { + if (isAggregate) { result = new UniqueResultObjectProvider(tmp, q, getQueryExpressions()); } else if (isAscending) { But though it looks like it's working better. Now I'm hitting another bug, that it looks like somehow the old EnityManager/Broker is being reused across requests. I know this because it works fine for first request, but second request complains that the Broker is already closed. So I might be opening up a new bug for that.

          People

          • Assignee:
            Pinaki Poddar
            Reporter:
            Fernando Padilla
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development