Announcement Announcement Module
Collapse
No announcement yet.
JPA - sort by aggregated fields. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JPA - sort by aggregated fields.

    Hi,


    I have a query in spring-data and I'm using pagination repository.
    I'm having issues with sorting (using the Pageable object) when it comes does to sort by aggregated fields...
    for example - assuming I have a

    Code:
    public class Job {
    
        @OneToMany(fetch = FetchType.LAZY)
        @JoinColumn(name = "job_id")
        private Set<SomeObject> someObjects;
    }
    my query is
    Code:
    select j.id, count(j.someObjects) from Job
    and I'd like to sort based on the count() .

    I've tried numerous options - none were successful.. (such as providing alias to the field, sort by "count(j....)")
    btw - JPA provider is hibernate 4
    any help would be greatly appreciated


    Yoni
Working...
X