I've been trying to make a more complex query than I'm used to, but try as I might I can't seem to get the syntax correct.
Is it possible to query the database for a persisted object which has both a Unique foreign key, and a maximum primary key?
That is, if I have multiple objects with the same foreign key and I want all of the ones which have the highest primary key and unique foreign key
1: fk: 4 pk: 1
2: fk: 4 pk: 2
3: fk: 7 pk: 3
4: fk: 7 pk: 4
5: fk: 7 pk: 5
6: fk: 9 pk: 6
7: fk: 9 pk: 7
I want entry 2 because it is the highest id with fId 4
I want etnry 5 because it is the highest id with fId 7
I want entry 7 because it is the highest id with fId 9
|