HQL查询中的几个函数

1.elements:此函数返回所有对象集合
例如:  select elements(blog.Comments) from Blog blog  返回全部blog对象的全部Comment
2.size:此函数计算集合的长度
例如: from Cat cat where size(cat.kittens) > 0
3.maxindex函数得到集合的最大索引数
 例如:from Cat cat where maxindex(cat.kittens) >1000  
    当cat对象中kittens集合的最大索引大于1000时,,,返回cat
3.maxelement函数得到集合的值
 例如:from Cat cat where maxelement(cat.kittens) >1000   
    当cat对象中kittens集合中的最大值大于1000  时,,,返回cat

3.index函数
 例如:from Cat cat where index(cat.kittens) >12 
    当cat对象中kittens集合中的索引大于12时,,,返回cat




http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html
原文地址:https://www.cnblogs.com/pojia/p/846260.html