OpenJPA
  1. OpenJPA
  2. OPENJPA-187

MEMBER OF query fails on OpenJPA, but works fine with TopLink and Hibernate EM

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.7
    • Fix Version/s: 1.2.0, 1.3.0
    • Component/s: query
    • Labels:
      None

      Description

      What's wrong with the following query?

      Query query = em.createQuery("SELECT DISTINCT o FROM Osoba o WHERE :projekt MEMBER OF o.projekty");
      query.setParameter("projekt", new Projekt("Apache OpenEJB", RodzajProjektu.OTWARTY));
      List<Osoba> osoby = query.getResultList();
      assert osoby.size() == 1 : "Otrzymano " + osoby.size();

      where Projekt is an entity where @Id is of type String (the first input parameter in the two-param constructor above).

      TopLink 2.0 BUILD 40 and Hibernate EntityManager 3.3.0.GA work fine whereas OpenJPA 0.9.7-SNAPSHOT finishes with the java.lang.AssertionError error (it's the test itself actually, but since the query returns 0 elements the issue originates in OpenJPA).

        Activity

        Hide
        Abe White added a comment -

        Does it work if you actually look up the "Apache OpenEJB" Projekt instance through the EntityManager rather than constructing a new one? It might be that OpenJPA is recognizing that the given Projekt isn't actually persistent.

        Show
        Abe White added a comment - Does it work if you actually look up the "Apache OpenEJB" Projekt instance through the EntityManager rather than constructing a new one? It might be that OpenJPA is recognizing that the given Projekt isn't actually persistent.
        Hide
        Patrick Linskey added a comment -

        I think that this is a new feature request, not a bug. It sounds like a neat feature, but I do not think that it's required behavior per the spec, and probably has an easy workaround (look up the instance first).

        Show
        Patrick Linskey added a comment - I think that this is a new feature request, not a bug. It sounds like a neat feature, but I do not think that it's required behavior per the spec, and probably has an easy workaround (look up the instance first).
        Hide
        Pinaki Poddar added a comment -

        This commit extends the ability to accept an unmanaged or transient instance as query parameter. This was available for managed entities only.
        This addition is limited to parameter entities with their primary key fields populated and subjected to peer review.
        This feature may also open up a discussion on how to support query-by-example pattern.

        I learned
        a) 'Osoba' means 'Person' in Polish. 'Osoby' is plural
        b) 'Project' is spelled 'Projekt' in Polish. It splural form is 'Projekty'

        Show
        Pinaki Poddar added a comment - This commit extends the ability to accept an unmanaged or transient instance as query parameter. This was available for managed entities only. This addition is limited to parameter entities with their primary key fields populated and subjected to peer review. This feature may also open up a discussion on how to support query-by-example pattern. I learned a) 'Osoba' means 'Person' in Polish. 'Osoby' is plural b) 'Project' is spelled 'Projekt' in Polish. It splural form is 'Projekty'
        Hide
        Michael Dick added a comment -

        Resolving issue after porting to 1.2.0

        Show
        Michael Dick added a comment - Resolving issue after porting to 1.2.0

          People

          • Assignee:
            Pinaki Poddar
            Reporter:
            Jacek Laskowski
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development