Hi,
i have a question regarding JPA and "Order By". I have the following class hierarchy:
- BaseAccount
|
|-> CustomerAccount
|-> BusinessAccount
The inheritance strategy is JOINED. I want to retrieve a list of BaseAccount's ordered by their subclass. E.g. first all BusinessAccounts and then all CustomerAccounts. Is there a way to formulate this in JPQL? This is the first time i have this requirement and googling for "JPA order by subclass" revealed nothing.
Has anybody an idea how to achieve this? I'm using Hibernate Entity Manager but would preferr to solve this using pure JPA.
My first idea was to use a discriminator column but this hasn't worked so far.
Thanks very much in advance.
best regards,
Sebastian
i have a question regarding JPA and "Order By". I have the following class hierarchy:
- BaseAccount
|
|-> CustomerAccount
|-> BusinessAccount
The inheritance strategy is JOINED. I want to retrieve a list of BaseAccount's ordered by their subclass. E.g. first all BusinessAccounts and then all CustomerAccounts. Is there a way to formulate this in JPQL? This is the first time i have this requirement and googling for "JPA order by subclass" revealed nothing.
Has anybody an idea how to achieve this? I'm using Hibernate Entity Manager but would preferr to solve this using pure JPA.
My first idea was to use a discriminator column but this hasn't worked so far.
Thanks very much in advance.
best regards,
Sebastian