0

I have the following entites:

@Entity
public class Employee {
       @Column
       private String employeeName;

       @Column
       private Integer employeeId;

       @OnetoMany
       private Set<Account> accounts;
}

@Entity
public class Account {
       @Column
       private String bankName;

       @Column
       private Integer accountNumber; 
}


public class EmployeeAccountRecords {
       private String employeeName;
       private Integer accountNumber;
}

I want to get paginated results of join of Employee and Account and store the value in objects of EmployeeAccountRecords class. Further I would also like to pass sorting/filter to the repository implementing this.

Can this be done without writing queries in JPQL/HQL, may be using JPA specification etc, any other components ?

I am using Spring Data JPA with Hibernate.

Thank you.

PS: result object is using only a subset of result set from the join values.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
Bleamer
  • 637
  • 9
  • 24

1 Answers1

0

Without using JPQL/HQL, the other two options I see are Spring Data JPA Specifications and QueryDsl.

As per the links Support projections on query methods that take a dynamic query type Specification or Querydsl Predicate and Add support for QueryDSL projections in JPA repositories they don't have support for Projections yet.

But they do have link that shows how to extend repository and support these features in querydsl http://stackoverflow.com/questions/18300465/spring-data-and-querydsl-to-fetch-subset-of-columns-using-bean-constructor-proje and other one is specification-with-projection and might help.