We have the following JPA class:
@Entity class Supplier { // ... id property etc. @OneToMany @OrderBy("someProperty") private List<Region> regions; }
This works fine in the normal case. However, we have several multilingual data in which values ββare stored in properties such as nameEn
, nameDe
, nameZh
. The exact property to use depends on the registered user. For example, a German-speaking user should see the regions as if they were annotated using @OrderBy("nameDe")
.
How can I achieve this?
I know that I could sort the collection in my code after loading it, but this makes it difficult to paginate the results.
java jpa
David sykes
source share