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

Completness tests fail with generated implementation classes for interfaces

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • JDO 2 rc1
    • JDO 2 final (2.0)
    • tck
    • None

    Description

      Completeness tests fail while comparing collections of persistent interfaces. This is because EqualityHelper invokes Collections.sort(Collection), which requires that the instances in the parameter Collection implement compareTo. The instances are not required by the specification to implement compareTo; therefore a Comparator must be provided to the sort method.

      Further, classes Department and FullTimeEmployee incorrectly cast to the class instead of the interface in the deepCompareFields method.

      Finally, the root classes Address, Company, Department, Insurance, Person, and Project need to implement the compare(Object, Object) methods directly, as there are three instances involved: the Comparator instance, which is an instance of the class, and the two instances to be compared. Both of the instances to be compared might be of the JDO-generated classes, which don't implement any comparison methods. The compare(Object, Object), compareTo(Object), and compareTo(SpecificInterface) should be refactored to use a common implementation using only the interface for comparison.

      As a specification activity beyond JDO 2.0, we might consider adding metadata to require the JDO implementation to generate comparison methods from the Comparable or Comparator interfaces based on field values. For datastore identity, simply tagging the interfaces, e.g. "interface IDepartment extends Comparable", doesn't give the implementation enough information as to which fields to compare.

      Attachments

        1. JDO-364.patch
          18 kB
          Michael Bouschen

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            mbo Michael Bouschen
            clr Craig L Russell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment