熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

Hibernate中Query對象的使用

2022-06-13   來源: Java開源技術 

個或多個屬性查詢:
?Query query=sessioncreateQuery(select customernamecustomerid from Customer)
?List l=querylist();
?For(int i=;i<lsize();i++)
{
?Obejct[] object=(Object[])lget(i);
?Object[]? object[]
}
}
分組: &#;select count(*)productname from Product group by productname order by productname&#;
取值與屬性一樣
配置的查詢在*hbmxml中
?<query name=&#;sql&#;>
? <![CDATA[
? ?from Product where productid=:productid
? ]]>
</query>
?Query query=sessiongetNamedQuery(sql);
聯接
?&#;from Customer as customer join fetch customerbuySet&#;將多的放到buySet屬性中得出的結是Customer有一個Buy有多個
聯接
&#;from Customer as customer join customerbuySet&#;:得出的對象customer與buy是
子查詢:
?&#;from Customer as customer where (select count(*) from customerbuySet)>&#;


From:http://tw.wingwit.com/Article/program/Java/ky/201405/30837.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.