Uploaded image for project: 'JDO'
  1. JDO
  2. JDO-763

RI does not implement default of Query.setResult

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • JDO 3.2
    • JDO 3.2
    • tck
    • None

    Description

      The JDO spec defines in chapter 14.6.9 "Specifying the Result of a Query (Projections, Aggregates)":
      Default Result
      If not specified, the result defaults to “distinct this as C” where C is the unqualified name of the candidate class. For example, the default result specification for a query where the candidate class is com.acme.hr.Employee is “distinct this as Employee”.

      The following query specifies a result class and assumes that the query result defaults to "distinct this as Person".
      Query query = pm.newQuery(Person.class, "lastname == 'emp1Last'");
      //query.setResult("distinct this as Person");
      query.setResultClass(PersonWrapper.class);
      Object results = query.execute();
      The above code results in org.datanucleus.exceptions.NucleusUserException: Query needs to return objects of type "org.apache.jdo.tck.query.api.SetResultDefault$PersonWrapper" but it was impossible to set the field "birthdate" type "java.util.Date". The field should have either a public set/put method, or be public.

      The query executes OK when explicitly specifying a result (see line in comments).

      Attachments

        1. SetResultDefault-patch.txt
          4 kB
          Michael Bouschen

        Activity

          People

            mbo Michael Bouschen
            mbo Michael Bouschen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: