@OrderBy: Sorting references

Posted by Sven Moschel on Stack Overflow See other posts from Stack Overflow or by Sven Moschel
Published on 2012-04-04T05:27:00Z Indexed on 2012/04/04 5:28 UTC
Read the original article Hit count: 133

Filed under:
|
|
|

We have the following entity structure:

@Entity
public class SecurityRole {
    private List<Account> accounts;   // ManyToMany
}

@Entity
public class Account {
    private Employee owner;   // OneToOne
}

@Entity
public class Employee {
    private String lastName;
}

A security role can have many accounts. A account always has an employee.

On the GUI we show the security roles in an mastertable. In the detail table we show the accounts of the role. To display the employee information we show "account.getOwner().getLastName()";

How can we use the @OrderBy annotation with this model? Is this possible? The problem is that the Account entity has no employee information that we can sort.

© Stack Overflow or respective owner

Related posts about sorting

Related posts about order-by