How to use Hibernate :

后端 未结 2 1059
南笙
南笙 2020-12-06 13:40

i am new to hibernate. i need to understand the following questions :

(1) What is subselect in hibernate mapping?

(2) How to map subselect in hbm file?

2条回答
  •  难免孤独
    2020-12-06 14:05

    Actually you don't need to model subselects, you can create queries that uses them. Check: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-subqueries

    (Edit: example from the link above)

    String hql = "from Cat as fatcat "+
                 "where fatcat.weight > ( "+
                 "  select avg(cat.weight) from DomesticCat cat "+
                 ")";
    List fatcats = session.createQuery(hql);
    

提交回复
热议问题