poorthingy
poorthingy

Reputation: 11

Hibernate max() query

I need to select a records where extId == parameter i give and from those records i want the latest by date (createDate property). Im trying this :

select r from Record r where r.extId=:eid and r.createDate=(select max(r.createDate) from r where r.id=r.id)

simply returns latest record. Help me please.

Upvotes: 0

Views: 472

Answers (1)

mstzn
mstzn

Reputation: 2921

You can try this query,it works for me.

from Record r where r.extId=:eid and r.createDate IN (select max(r2.createDate) from Recordr2)

Upvotes: 2

Related Questions