|
|
|
|
Re: @OrderBy problem [message #1711582 is a reply to message #825186] |
Sat, 17 October 2015 18:18 |
|
Thank You, James - that hint was very helpful. A DescriptorCustomizer can be used to achieve the requirement. In my case, I needed something similar to "JPQL Path Expressions", to navigate through Entities and related objects, for getting a @OneToMany list sorted. (hint: native @orderBy(...) is only applicable to more trivial cases, as far as I know, no path expressions / navigation allowed there)
@Entity
@Table(name = BmAccount.bm_account)
@Customizer(BmAccountE.BmAccountECustomizer.class)
public class BmAccountE implements Serializable {
public static class BmAccountECustomizer implements DescriptorCustomizer {
@Override
public void customize(ClassDescriptor descriptor) throws Exception {
OneToManyMapping o2m = ((OneToManyMapping) descriptor
.getMappingForAttributeName("accountUsers"));
ReadAllQuery raq = (ReadAllQuery) o2m.getSelectionQuery();
raq.addOrdering(raq.getExpressionBuilder()
.get("user").get("userName").toUpperCase().ascending());
}
}
...
|
|
|
Powered by
FUDForum. Page generated in 0.03804 seconds