I have the following relationships in JPA (hibernation).
Object X has two subclasses: Y and Z.
Object A has manyToOne related to object X. (Note that this is a one-way relationship, so object X cannot see object A).
Now I want to get the maximum value of the column in object A, but only where the relation has a certain subtype, that is ... Y.
So this is equivalent ... to get the maximum value of column1 in object A, in all instances of A, where they relate to Y. Is this possible? I lost a little how to request it.
I was thinking of something like:
String query = "SELECT MAX(a.columnName) FROM A a join a.x;
Query query = super.entityManager.createQuery(query);
query.execute();
However, this does not account for subclass X ... so I lost a bit.
Any help would be greatly appreciated.