开发者

Hibernate advanced select

开发者 https://www.devze.com 2022-12-25 07:47 出处:网络
We want to get a row from a开发者_Python百科 table using Hibernate a la: select max(id) from mytable where date = <date>

We want to get a row from a开发者_Python百科 table using Hibernate a la:

  1. select max(id) from mytable where date = <date>
  2. Then select * from mytable where id = <max_id>

We are currently using Hibernate to map mytable to Java domain objects.

I know how to load the domain object based on an id. So I could just do #1 using JDBC and then load the domain object using Hibernate the "normal" way.

But.. is there a way to do this with one single Hibernate logical query?


Try using subqueries.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号