I'm trying to get the most recent data that isn't going to be applied until future dates.
For now i'm using the following HQL:
int x = goods.getId()
String hql = "FROM PriceTags as atcl WHERE atcl.goods_id = '"+x+"' AND atcl.updatedDate <= CURTIME() ORDER BY updatedDate DESC";
return (PriceTags) entityManager.createQuery(hql).setMaxResults(1).getSingleResult();
this will return all the pricetags with an updatedDate that is less or equal to the current time and order it descendingly. After that i just use the first entry it returns. Is it possible to make a HQL that gets all most updated pricetags for all goods?
For an example the table PriceTags will contain :
Id goods_id price updatedDate
1 101 100 2019-07-30
2 101 150 2019-07-31
3 102 120 2019-07-28
4 102 90 2019-06-29
5 102 130 2020-01-01
Lets say current day is 2019-08-01 i would like to get row 2 and 3, since they're the most recent entry up until current day. row 5 wont be relevant until january next year thus wont be returned.