Hi,
i am looking for a way to get the minimal date of a collection of share prices for a given company. It should be something like:
Code:
select min(c.sharePrices.date) from Company c where c = :company
But I get an error message:
Code:
QueryException: illegal attempt to dereference collection [company0_.id.sharePrices] with element property reference [date]
Also the intuitive
Code:
select min(s.date) from SharePrice s, Company c where c = :company and s in c.sharePrices
does not work, because it is translated to:
Code:
select min(shareprice0_.date) as col_0_0_ from SharePrice shareprice0_, Company company1_, Company_SharePrice shareprice2_, SharePrice shareprice3_ where company1_.id=shareprice2_.Company_id and shareprice2_.sharePrices_id=shareprice3_.id and company1_.id=? and (shareprice0_.id in (.))
I am relatively new to Hibernate. Can anybody give me a hint on how to do this query properly?
Thanks!
korpe