Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-162

@OrderBy on @OneToMany does not allow ordering by @Id value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9.6
    • 0.9.7
    • jpa
    • None
    • Using PostgreSQL 8.1 as the database

    Description

      Using the following annotation:

      @OneToMany(mappedBy="root", fetch=FetchType.LAZY)
      @OrderBy("objectId ASC")
      private List<Message> messages;

      I get the exception "Cannot order "net.spatula.tally_ho.model.MessageRoot.messages" on "objectId", because that field is not in the default fetch group. You can only order on fields that will be selected when the related object is loaded."

      I should certainly hope that the primary key of the related object is going to be selected when the object is loaded:

      @Id
      @Column(name = "object_id")
      private long objectId;

      Attachments

        Activity

          People

            Unassigned Unassigned
            spatula Nick Johnson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: