How does @OrderBy work?
It is not working here in the following code:
Employee.java
package com.semanticbits.po
I think you're misunderstanding what the @Orderby annotation actually does. According to the javadoc:
Specifies the ordering of the elements of a collection valued association or element collection at the point when the association or collection is retrieved.
[emphasis added] The annotation does not dictate insertion order. Continuing with your example, if you were to fetch an Employee:
Employee employee = manager.find(Employee.class, employeeId);
List<Address> addresses = employee.getAddress();
Then addresses would be sorted by city in descending order.
according to the spec you would have to use:
@OrderBy("address.city DESC")